<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>bosdyn.client.command_line &mdash; Spot 5.0.1.1 documentation</title>
      <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/style.css" type="text/css" />
    <link rel="shortcut icon" href="../../../_static/bd-favicon.png"/>
    <link rel="canonical" href="https://dev.bostondynamics.com/_modules/bosdyn/client/command_line.html" />
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    <script src="../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../README.html">
            
              <img src="../../../_static/bd-official-white.png" class="logo" alt="Logo"/>
          </a>
              <div class="version">
                5.0.1.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/concepts/README.html">Concepts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/about_spot.html">About Spot</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/orbit/about_orbit.html">About Orbit (formerly Scout)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/orbit/orbit_api.html">Orbit API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/networking.html">Networking</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/base_services.html">Base services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/geometry_and_frames.html">Geometry and Frames</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/robot_services.html">Robot services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/estop_service.html">E-Stop</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/keepalive_service.html">KeepAlive (BETA)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/audio_visual.html">Audio Visual</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/lease_service.html">Lease</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/developing_api_services.html">Developing API Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/service_customization.html">Service Customization</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/faults.html">Faults</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/autonomy/README.html">Autonomy services</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_tech_summary.html">Autonomy Technical Summary</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/autonomous_navigation_code_examples.html">Autonomous navigation code examples</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/components_of_autonomous_navigation.html">Components of autonomous navigation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/docking.html">Docking</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/typical_autonomous_navigation_use_case.html">Typical autonomous navigation use case</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/autonomous_navigation_services.html">Autonomous navigation services</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_service.html">GraphNav service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_map_structure.html">GraphNav map structure</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_area_callbacks.html">GraphNav area callbacks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/initialization.html">Initialization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/localization.html">Localization</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/graphnav_and_robot_locomotion.html">GraphNav and robot locomotion</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/missions_service.html">Missions service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/autowalk_service.html">Autowalk service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/network_compute_bridge.html">Network compute bridge</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/auto_return.html">AutoReturn service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/directed_exploration.html">Directed Exploration</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/autonomy/gps.html">GPS</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/choreography/README.html">Choreography</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreography_service.html">Choreography Service</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/move_reference.html">Move Reference Guide</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/custom_gait.html">CustomGait Reference</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreographer_setup.html">Choreographer Setup</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreographer.html">Choreographer Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/robot_controls_in_choreographer.html">Robot Connections in Choreographer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/animations_in_choreographer.html">Animations in Choreography</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/animation_file_specification.html">Animation File Format</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreography_in_tablet.html">Tablet Choreography Mode</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/choreography/choreography_in_autowalk.html">Choreography Actions in Autowalk</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/joint_control/README.html">Joint Control API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/joint_control/supplemental_data.html">Supplemental Robot Information</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../docs/concepts/joint_control/knee_torque_limits.html">Knee Torque Limits</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/arm/README.html">Spot Arm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/arm/arm_specification.html">Arm and Gripper Specification</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/arm/arm_concepts.html">Concepts</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/arm/arm_services.html">Services</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/concepts/data.html">Spot Data</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_acquisition_overview.html">Data Acquisition Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_acquisition_output.html">Data Acquisition Output</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/writing_services_for_data_acquisition.html">Integrate Payloads with the API</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_buffer_overview.html">Data Buffer Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/bddf.html">BDDF File Format</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/concepts/data_acquisition_thermal_raw.html">Thermal Raw Data Format</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/python/README.html">Python</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/quickstart.html">Quickstart</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/understanding_spot_programming.html">Understanding Spot Programming</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../python/examples/README.html">Examples</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/basic_service_examples.html">Basic Service Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/hello_spot/README.html">Hello Spot</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/directory/README.html">Directory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_robot_state/README.html">Get Robot State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_robot_state_async/README.html">Get Robot State Async</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_image/README.html">Get Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_world_objects/README.html">Get World Objects</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_mission_state/README.html">Get Mission State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/estop/README.html">E-Stop</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/time_sync/README.html">Time Sync</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/comms_test/README.html">Comms Test</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/disable_ir_emission/README.html">IR Enable/Disable</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/reset_safety_stop/README.html">Reset Safety Stop</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/audio_visual/audio_visual_params/README.html">Audio Visual Params</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/audio_visual/audio_visual_behaviors/README.html">Audio Visual Behaviors</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/robot_behavior_examples.html">Robot Behavior and Commands Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/stance/README.html">Stance</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/frame_trajectory_command/README.html">Frame Trajectory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_light/README.html">Spot Light</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/upload_choreographed_sequence/README.html">Upload Choreographed Sequence</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/xbox_controller/README.html">Xbox Controller</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/wasd/README.html">WASD</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/docking/README.html">Docking</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/animation_recorder/README.html">Animation Recorder</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/auto_return/README.html">Auto Return</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/fan_command/README.html">Fan Commands</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_wasd/README.html">ARM WASD</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/arm_examples.html">Arm Command Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_simple/README.html">Simple Arm Motion</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_stow_unstow/README.html">Stow/unstow Arm</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_freeze/README.html">Arm Freeze</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_and_mobility_command/README.html">Arm and Mobility Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_with_body_follow/README.html">Arm Command with Body Following</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_constrained_manipulation/README.html">Arm Constrained Manipulation</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_trajectory/README.html">Arm Trajectory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_trajectory/README.html#long-trajectory">Long Trajectory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_joint_move/README.html">Arm Joint Move Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_force_control/README.html">Arm Force Control Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_grasp/README.html">Arm Grasp Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_grasp_carry_overrides/README.html">Arm Grasp and Carry Overrides</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_gaze/README.html">Arm Gaze Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_surface_contact/README.html">Arm Command with Surface Contact</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_door/README.html">Arm Door Opening Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_walk_to_object/README.html">Walk to And Pick Up Object</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_gcode/README.html">Writing Gcode</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/gripper_camera_params/README.html">Gripper Camera Parameters</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_impedance_control/README.html">Arm Impedance Control</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/inverse_kinematics/README.html">Inverse Kinematics</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/arm_wasd/README.html">Arm WASD</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/joint_control/README.html">Wiggle Arm</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/payloads_examples.html">Payloads and Registration Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/payloads/README.html">Payloads</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/self_registration/README.html">Self Registration</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_faults/README.html">Faults</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/velodyne_client/README.html">Velodyne</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/core_io_gpio/README.html">CORE I/O GPIO</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html">Overview</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html#usage">Usage</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html#components">Components</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/metrics_over_coreio/README.html#recommended-debugging">Recommended debugging</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/extensions/README.html">Extensions</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/perception_world_objects_examples.html">Perception and World Objects Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_image/README.html">Get Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_world_objects/README.html">Get World Objects</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/world_object_with_image_coordinates/README.html">World Object With Image Coordinates</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/world_object_mutations/README.html">World Object Mutations</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/visualizer/README.html">Visualizer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/gripper_camera_params/README.html">Gripper Camera Parameters</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_cam/README.html">Spot CAM Services</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_cam/README.html#spot-cam-video-core-io-extension-example">Spot Cam Video Core IO Extension Example</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/stitch_front_images/README.html">Stitch Front Images</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_depth_plus_visual_image/README.html">Project Depth Data on Visual Images</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameter_image_server/README.html">Custom Parameter Image Server</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/fiducial_follow/README.html">Fiducial Follow</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/spot_tensorflow_detector/README.html">Tensorflow Detector</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameter_ncb_worker/README.html">Custom Parameter Tensorflow Detector</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_compute_bridge/README.html">Machine Learning with the Network Compute Bridge</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_compute_bridge/fire_extinguisher_server/README.html">Fire Extinguisher Detector with the Network Compute Bridge</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/ray_cast/README.html">Ray Cast</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/user_nogo_regions/README.html">No-Go Regions</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/gps_service/README.html">GPS</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/logging_examples.html">Logging Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/bddf_download/README.html">BDDF Download</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_buffer/README.html">Data Buffer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_service/README.html">Data Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/logging/README.html">Logging</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/log_status/README.html">Log Status</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/data_acquisition_examples.html">Data Acquisition Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_acquisition_service/README.html">Data Acquisition Service</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/examples/data_acquisition_service/signals_coreio_modem_plugin/README.html">Modem Signals</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_faults/README.html">Faults</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameter_image_server/README.html">Custom Parameter Image Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/service_customization/custom_parameters_data_acquisition/README.html">Custom Parameter Data Acquisition Plugin</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_image/README.html">Test Image Service Implementation with Get Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/post_docking_callbacks/README.html">Post Docking Callbacks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/cloud_upload/README.html">Cloud Upload</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/comms_mapping/README.html">Comms image service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/comms_mapping/README.html#how-to-use">How to use</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/data_acquisition_service/signals_coreio_modem_plugin/README.html">CoreIO Modem Signals Plugin</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/tester_programs/README.html">Tester Programs</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/autonomy_and_missions_examples.html">Autonomy and Missions Examples</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_anchoring_optimization/README.html">Graph Nav Anchoring Optimization</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_command_line/README.html">GraphNav and Recording Service Command Line Interfaces</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_command_line/README.html#example-programs">Example Programs</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_extract_point_cloud/README.html">Graph Nav Extract Point Cloud</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_view_map/README.html">Graph Nav View Map</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/graph_nav_view_gps/README.html">Graph Nav View GPS Data</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/get_mission_state/README.html">Get Mission State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/remote_mission_service/README.html">Remote Mission Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/mission_question_answerer/README.html">Mission Question Answerer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/mission_recorder/README.html">Mission Recorder</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/replay_mission/README.html">Replay Mission</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/post_docking_callbacks/README.html">Post Docking Callbacks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/area_callback/README.html">Area Callbacks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/edit_autowalk/README.html">Edit Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/record_autowalk/README.html">Record Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/extract_images_from_walk/README.html">Extract Images from Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_request_callback/README.html">Network Request Callback</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/network_request_callback/README.html#id1">Network Request Callback</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/remote_mission_service/spot_check/README.html">SpotCheck Mission Service</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/joint_control_examples.html">Joint Control API Examples</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/examples/docs/orbit.html">Orbit</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/hello_orbit/README.html">Hello Orbit</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/export_run_archives/README.html">Export Run Archives</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/export_site_walk_archives/README.html">Export Sitewalk Archives</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/anomalies/README.html">Anomalies</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/schedule_mission/README.html">Schedule Mission</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/runs_response/README.html">Runs Response</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/send_robot_back_to_dock/README.html">Return to Dock</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/toggle_mission_based_on_weather/README.html">Mission Toggle</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/webhook/README.html">Webhook</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/backups/README.html">Backups</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/webhook_integration/README.html">Webhook Integrations</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/examples/orbit/webhook_integration/README.html#example-overview">Example Overview</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../python/README.html">Python Reference Guide</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/README.html">Client</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback.html">Area Callback</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_region_handler_base.html">Area Callback Region Handler</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_service_runner.html">Area Callback Service Runner</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_service_servicer.html">Area Callback Servicer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/area_callback_service_utils.html">Area Callback Service Utils</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/arm_surface_contact.html">Arm Surface Contact</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/async_tasks.html">Async Tasks</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/audio_visual.html">Audio Visual</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/audio_visual_helpers.html">Audio Visual Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/auth.html">Auth</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/auto_return.html">Auto Return</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/autowalk.html">Autowalk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/bddf.html">BDDF</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/bddf_download.html">BDDF Download</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/channel.html">Channel</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html">Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/common.html">Common</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition.html">Data Acquisition</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_helpers.html">Data Acquisition Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_plugin.html">Data Acquisition Plugin</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_plugin_service.html">Data Acquisition Plugin Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_acquisition_store.html">Data Acquisition Store</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_buffer.html">Data Buffer</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_chunk.html">Data Chunk</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/data_service.html">Data Service</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/directory_registration.html">Directory Registration</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/directory.html">Directory</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/docking.html">Docking</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/door.html">Door</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/estop.html">E-Stop</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/error_callback_result.html">Error Callback Result</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/exceptions.html">Exceptions</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/fault.html">Fault</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/frame_helpers.html">Frame Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/graph_nav.html">Graph Nav</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gripper_camera_param.html">Gripper Camera Params</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/README.html">GPS</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/aggregator_client.html">Aggregator Client</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/gps_listener.html">GPS Listener</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/NMEAParser.html">NMEA Parser</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/ntrip_client.html">NTRIP Client</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/gps/registration_client.html">Registration Client</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/image.html">Image</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/image_service_helpers.html">Image Service Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/inverse_kinematics.html">Inverse Kinematics</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/ir_enable_disable.html">IR Enable/Disable</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/keepalive.html">Keep Alive</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/lease.html">Lease</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/lease_resource_hierarchy.html">Lease Resource Hierarchy</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/lease_validator.html">Lease Validator</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/license.html">License</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/local_grid.html">Local Grid</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/log_status.html">Log Status</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/math_helpers.html">Math Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/manipulation_api_client.html">Manipulation API</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/map_processing.html">Map Processing</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/metrics_logging.html">Metrics Logging</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/network_compute_bridge_client.html">Network Compute Bridge</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload_registration.html">Payload Registration</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload_software_update.html">Payload Software Update</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload_software_update_initiation.html">Payload Software Update Initiation</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/payload.html">Payload</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/point_cloud.html">Point Cloud</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/power.html">Power</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/processors.html">Processors</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/ray_cast.html">Ray casting</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/recording.html">Recording</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot_command.html">Robot Command</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot_id.html">Robot ID</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot.html">Robot</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/robot_state.html">Robot State</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/sdk.html">SDK</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/server_util.html">Server Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/service_customization_helpers.html">Service Customization Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/signals_helpers.html">Signals Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/README.html">Spot CAM</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/audio.html">Audio</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/compositor.html">Compositor</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/health.html">Health</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/lighting.html">Lighting</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/lights_helper.html">Lights Helper</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/media_log.html">Media Log</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/network.html">Network</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/power.html">Power</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/ptz.html">PTZ</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/streamquality.html">Stream Quality</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_cam/version.html">Version</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/spot_check.html">Spot Check</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/time_sync.html">Time Sync</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/token_cache.html">Token Cache</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/token_manager.html">Token Manager</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/units_helpers.html">Units Helpers</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/util.html">Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-client/src/bosdyn/client/world_object.html">World Object</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/README.html">Core</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/README.html">BDDF</a><ul>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/base_data_reader.html">Base Data Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/block_writer.html">Block Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/bosdyn.html">BDDF Conventions</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/common.html">Common</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/data_reader.html">Data Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/data_writer.html">Data Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/file_indexer.html">File Indexer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_proto_reader.html">GRPC Proto Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_reader.html">GRPC Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_service_reader.html">GRPC Service Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/grpc_service_writer.html">GRPC Service Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/message_reader.html">Message Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/pod_series_reader.html">POD Series Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/pod_series_writer.html">POD Series Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/protobuf_channel_reader.html">Protobuf Channel Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/protobuf_reader.html">Protobuf Reader</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/protobuf_series_writer.html">Protobuf Series Writer</a></li>
<li class="toctree-l5"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/bddf/stream_data_reader.html">Stream Data Reader</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/geometry.html">Geometry</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/util.html">Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-core/src/bosdyn/deprecated.html">Deprecated</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/README.html">Mission</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/client.html">Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/constants.html">Constants</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/exceptions.html">Exceptions</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/remote_client.html">Remote Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/server_util.html">Server Util</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-mission/src/bosdyn/mission/util.html">Util</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/README.html">Choreography</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/choreography.html">Choreography</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/animation_file_to_proto.html">Animation File to Proto</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-choreography-client/src/bosdyn/choreography/client/animation_file_conversion_helpers.html">Animation File to Proto Helpers</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/README.html">Orbit (formerly Scout)</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/client.html">Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/utils.html">Utils</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-orbit/src/bosdyn/orbit/exceptions.html">Exceptions</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/README.html">Scout (deprecated)</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/client.html">Client</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/utils.html">Utils</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../../python/bosdyn-scout/src/bosdyn/scout/exceptions.html">Exceptions</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch1.html">Fetch Tutorial</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch2.html">Part 2: Training the Model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch3.html">Part 3: Evaluating the Model</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch4.html">Part 4: Autonomous Pick Up</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch5.html">Part 5: Detecting People and Playing Fetch</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/fetch_tutorial/fetch6.html">Part 6: Running the model on Core IO</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq1.html">Data Collection Tutorial</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq2.html">Part 2: Capturing images</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq3.html">Part 3: Capturing other data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq4.html">Part 4: Deploying to the CORE I/O</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq5.html">Part 5: Collecting data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/python/daq_tutorial/daq6.html">Part 6: Processing collected data</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/payload/README.html">Payloads</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/payload_configuration_requirements.html">Payload configuration requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/mechanical_interfaces.html">Mechanical interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/robot_mounting_rails.html">Robot mounting rails</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/guidelines_for_robust_payload_design.html">Guidelines for robust payload design</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/robot_electrical_interface.html">Robot electrical interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/coreio_documentation.html">CORE I/O Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/coreio_openvpn_extension.html">CORE I/O OpenVPN Extension</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/configuring_payload_software.html">Configuring payload software</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/docker_containers.html">Dockerize payload software</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/payload/spot_core_documentation.html">Pre-3.2 Spot CORE Documentation</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/payload/spot_core_portainer.html">Configuring Docker containers in SpotCORE</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/payload/spot_core_cockpit.html">Spot CORE system management tool: Cockpit</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../docs/payload/spot_core_vnc.html">Spot CORE VNC</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/protos/README.html">API Protocol</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../docs/protos/style_guide.html">Style Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../protos/bosdyn/api/README.html">Proto Reference Guide</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../protos/bosdyn/api/proto_reference.html">Protos</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../docs/release_notes.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/boston-dynamics/spot-sdk">SDK Repository</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../README.html">Spot</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../README.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../index.html">Module code</a></li>
      <li class="breadcrumb-item active">bosdyn.client.command_line</li>
      <li class="wy-breadcrumbs-aside">
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <h1>Source code for bosdyn.client.command_line</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) 2023 Boston Dynamics, Inc.  All rights reserved.</span>
<span class="c1">#</span>
<span class="c1"># Downloading, reproducing, distributing or otherwise using the SDK Software</span>
<span class="c1"># is subject to the terms and conditions of the Boston Dynamics Software</span>
<span class="c1"># Development Kit License (20191101-BDSDK-SL).</span>

<span class="c1"># Boston Dynamics, Inc. Confidential Information.</span>
<span class="c1"># Copyright 2025. All Rights Reserved.</span>
<span class="sd">&quot;&quot;&quot;Command-line utility code for interacting with robot services.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">division</span>

<span class="kn">import</span> <span class="nn">abc</span>
<span class="kn">import</span> <span class="nn">argparse</span>
<span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">signal</span>
<span class="kn">import</span> <span class="nn">socket</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">import</span> <span class="nn">time</span>

<span class="kn">from</span> <span class="nn">deprecated.sphinx</span> <span class="kn">import</span> <span class="n">deprecated</span>
<span class="kn">from</span> <span class="nn">google.protobuf</span> <span class="kn">import</span> <span class="n">json_format</span>

<span class="kn">import</span> <span class="nn">bosdyn.client</span>
<span class="kn">from</span> <span class="nn">bosdyn.api</span> <span class="kn">import</span> <span class="n">data_acquisition_pb2</span><span class="p">,</span> <span class="n">image_pb2</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.data_buffer_pb2</span> <span class="kn">import</span> <span class="n">Event</span><span class="p">,</span> <span class="n">TextMessage</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.data_index_pb2</span> <span class="kn">import</span> <span class="n">EventsCommentsSpec</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.keepalive</span> <span class="kn">import</span> <span class="n">keepalive_pb2</span>
<span class="kn">from</span> <span class="nn">bosdyn.api.robot_state_pb2</span> <span class="kn">import</span> <span class="n">BehaviorFault</span>
<span class="kn">from</span> <span class="nn">bosdyn.util</span> <span class="kn">import</span> <span class="n">duration_str</span><span class="p">,</span> <span class="n">timestamp_to_datetime</span>

<span class="kn">from</span> <span class="nn">.auth</span> <span class="kn">import</span> <span class="n">InvalidLoginError</span><span class="p">,</span> <span class="n">InvalidTokenError</span>
<span class="kn">from</span> <span class="nn">.data_acquisition</span> <span class="kn">import</span> <span class="n">DataAcquisitionClient</span>
<span class="kn">from</span> <span class="nn">.data_acquisition_helpers</span> <span class="kn">import</span> <span class="n">acquire_and_process_request</span>
<span class="kn">from</span> <span class="nn">.data_acquisition_plugin</span> <span class="kn">import</span> <span class="n">DataAcquisitionPluginClient</span>
<span class="kn">from</span> <span class="nn">.data_buffer</span> <span class="kn">import</span> <span class="n">DataBufferClient</span>
<span class="kn">from</span> <span class="nn">.data_service</span> <span class="kn">import</span> <span class="n">DataServiceClient</span>
<span class="kn">from</span> <span class="nn">.directory</span> <span class="kn">import</span> <span class="n">DirectoryClient</span><span class="p">,</span> <span class="n">NonexistentServiceError</span>
<span class="kn">from</span> <span class="nn">.directory_registration</span> <span class="kn">import</span> <span class="n">DirectoryRegistrationClient</span><span class="p">,</span> <span class="n">DirectoryRegistrationResponseError</span>
<span class="kn">from</span> <span class="nn">.estop</span> <span class="kn">import</span> <span class="n">EstopClient</span><span class="p">,</span> <span class="n">EstopEndpoint</span><span class="p">,</span> <span class="n">EstopKeepAlive</span>
<span class="kn">from</span> <span class="nn">.exceptions</span> <span class="kn">import</span> <span class="n">Error</span><span class="p">,</span> <span class="n">InvalidRequestError</span><span class="p">,</span> <span class="n">ProxyConnectionError</span>
<span class="kn">from</span> <span class="nn">.image</span> <span class="kn">import</span> <span class="p">(</span><span class="n">ImageClient</span><span class="p">,</span> <span class="n">ImageResponseError</span><span class="p">,</span> <span class="n">UnknownImageSourceError</span><span class="p">,</span> <span class="n">build_image_request</span><span class="p">,</span>
                    <span class="n">save_images_as_files</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">.keepalive</span> <span class="kn">import</span> <span class="n">KeepaliveClient</span>
<span class="kn">from</span> <span class="nn">.lease</span> <span class="kn">import</span> <span class="n">LeaseClient</span>
<span class="kn">from</span> <span class="nn">.license</span> <span class="kn">import</span> <span class="n">LicenseClient</span>
<span class="kn">from</span> <span class="nn">.local_grid</span> <span class="kn">import</span> <span class="n">LocalGridClient</span>
<span class="kn">from</span> <span class="nn">.log_status</span> <span class="kn">import</span> <span class="n">InactiveLogError</span><span class="p">,</span> <span class="n">LogStatusClient</span>
<span class="kn">from</span> <span class="nn">.payload</span> <span class="kn">import</span> <span class="n">PayloadClient</span>
<span class="kn">from</span> <span class="nn">.payload_registration</span> <span class="kn">import</span> <span class="n">PayloadAlreadyExistsError</span><span class="p">,</span> <span class="n">PayloadRegistrationClient</span>
<span class="kn">from</span> <span class="nn">.power</span> <span class="kn">import</span> <span class="p">(</span><span class="n">PowerClient</span><span class="p">,</span> <span class="n">power_cycle_robot</span><span class="p">,</span> <span class="n">power_off_payload_ports</span><span class="p">,</span> <span class="n">power_off_robot</span><span class="p">,</span>
                    <span class="n">power_off_wifi_radio</span><span class="p">,</span> <span class="n">power_on_payload_ports</span><span class="p">,</span> <span class="n">power_on_wifi_radio</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">.robot_id</span> <span class="kn">import</span> <span class="n">RobotIdClient</span>
<span class="kn">from</span> <span class="nn">.robot_state</span> <span class="kn">import</span> <span class="n">RobotStateClient</span>
<span class="kn">from</span> <span class="nn">.time_sync</span> <span class="kn">import</span> <span class="n">TimeSyncClient</span><span class="p">,</span> <span class="n">TimeSyncEndpoint</span><span class="p">,</span> <span class="n">TimeSyncError</span><span class="p">,</span> <span class="n">timespec_to_robot_timespan</span>
<span class="kn">from</span> <span class="nn">.util</span> <span class="kn">import</span> <span class="n">add_common_arguments</span><span class="p">,</span> <span class="n">authenticate</span><span class="p">,</span> <span class="n">setup_logging</span>



<span class="c1"># pylint: disable=too-few-public-methods</span>
<div class="viewcode-block" id="Command"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.Command">[docs]</a><span class="k">class</span> <span class="nc">Command</span><span class="p">(</span><span class="nb">object</span><span class="p">,</span> <span class="n">metaclass</span><span class="o">=</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Command-line command.</span>

<span class="sd">    Args:</span>
<span class="sd">        subparsers: List of argument parsers.</span>
<span class="sd">        command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># The name of the command the user should enter on the command line to select this command.</span>
    <span class="n">NAME</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="c1"># Whether authentication is needed before the command is run.</span>
    <span class="c1"># Most commands need authentication.</span>
    <span class="n">NEED_AUTHENTICATION</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
        <span class="n">command_dict</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">NAME</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span> <span class="o">=</span> <span class="n">subparsers</span><span class="o">.</span><span class="n">add_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NAME</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">)</span>

<div class="viewcode-block" id="Command.run"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.Command.run">[docs]</a>    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Invoke the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NEED_AUTHENTICATION</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">options</span><span class="p">,</span> <span class="s1">&#39;username&#39;</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">hasattr</span><span class="p">(</span>
                        <span class="n">options</span><span class="p">,</span> <span class="s1">&#39;password&#39;</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">username</span> <span class="ow">or</span> <span class="n">options</span><span class="o">.</span><span class="n">password</span><span class="p">):</span>
                    <span class="n">robot</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">username</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">password</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">authenticate</span><span class="p">(</span><span class="n">robot</span><span class="p">)</span>
                <span class="n">robot</span><span class="o">.</span><span class="n">sync_with_directory</span><span class="p">()</span>  <span class="c1"># Make sure that we can use all registered services.</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_run</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">ProxyConnectionError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Could not contact robot with hostname &quot;</span><span class="si">{}</span><span class="s1">&quot;.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">hostname</span><span class="p">),</span>
                  <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">InvalidTokenError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The provided user token is invalid.&#39;</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">InvalidLoginError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Username and/or password are invalid.&#39;</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">Error</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="n">err</span><span class="p">),</span> <span class="n">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span></div>

    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="Subcommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.Subcommands">[docs]</a><span class="k">class</span> <span class="nc">Subcommands</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Run subcommands.</span>

<span class="sd">    Args:</span>
<span class="sd">        subparsers: List of argument parsers.</span>
<span class="sd">        command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        subcommands: List of subcommands to run.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span> <span class="n">subcommands</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="n">command_dest</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">_command&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NAME</span><span class="p">)</span>
        <span class="n">cmd_subparsers</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_subparsers</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="n">command_dest</span><span class="p">)</span>
        <span class="n">cmd_subparsers</span><span class="o">.</span><span class="n">required</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_subcommands</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">subcommand</span> <span class="ow">in</span> <span class="n">subcommands</span><span class="p">:</span>
            <span class="n">subcommand</span><span class="p">(</span><span class="n">cmd_subparsers</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_subcommands</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Execution of the specific subcommand from the options.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">command_dest</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">_command&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NAME</span><span class="p">)</span>
        <span class="n">subcommand</span> <span class="o">=</span> <span class="nb">vars</span><span class="p">(</span><span class="n">options</span><span class="p">)[</span><span class="n">command_dest</span><span class="p">]</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_subcommands</span><span class="p">[</span><span class="n">subcommand</span><span class="p">]</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span></div>


<div class="viewcode-block" id="DirectoryCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DirectoryCommands">[docs]</a><span class="k">class</span> <span class="nc">DirectoryCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands related to the directory service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;dir&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands related to the directory service.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DirectoryCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span> <span class="p">[</span>
            <span class="n">DirectoryListCommand</span><span class="p">,</span> <span class="n">DirectoryGetCommand</span><span class="p">,</span> <span class="n">DirectoryRegisterCommand</span><span class="p">,</span>
            <span class="n">DirectoryUnregisterCommand</span>
        <span class="p">])</span></div>


<span class="k">def</span> <span class="nf">_format_dir_entry</span><span class="p">(</span>  <span class="c1"># pylint: disable=too-many-arguments</span>
        <span class="n">name</span><span class="p">,</span> <span class="n">service_type</span><span class="p">,</span> <span class="n">authority</span><span class="p">,</span> <span class="n">tokens</span><span class="p">,</span> <span class="n">name_width</span><span class="o">=</span><span class="mi">23</span><span class="p">,</span> <span class="n">type_width</span><span class="o">=</span><span class="mi">31</span><span class="p">,</span> <span class="n">authority_width</span><span class="o">=</span><span class="mi">27</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Prints the passed values as &quot;name service_type authority tokens&quot;, with the first three using</span>
<span class="sd">    the specified width.</span>

<span class="sd">    Args:</span>
<span class="sd">        name: Name of the service.</span>
<span class="sd">        service_type: Type of the service.</span>
<span class="sd">        authority: Authority of the service.</span>
<span class="sd">        tokens: Tokens required for using the service.</span>
<span class="sd">        name_width: Width for printing the name value.</span>
<span class="sd">        type_width: Width for printing the service_type value.</span>
<span class="sd">        authority_width: Width for printing the authority value.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="nb">print</span><span class="p">((</span><span class="s1">&#39;{:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">name_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">type_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">authority_width</span><span class="p">)</span> <span class="o">+</span>
           <span class="s1">&#39;} </span><span class="si">{}</span><span class="s1">&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">service_type</span><span class="p">,</span> <span class="n">authority</span><span class="p">,</span> <span class="n">tokens</span><span class="p">))</span>


<span class="k">def</span> <span class="nf">_token_req_str</span><span class="p">(</span><span class="n">entry</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Returns a string representing tokens required for using the service.</span>

<span class="sd">    Args:</span>
<span class="sd">        entry: Service entry being checked.</span>

<span class="sd">    Returns:</span>
<span class="sd">        String with a comma-separated list of required tokens.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">required</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">if</span> <span class="n">entry</span><span class="o">.</span><span class="n">user_token_required</span><span class="p">:</span>
        <span class="n">required</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;user&#39;</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">required</span><span class="p">:</span>
        <span class="k">return</span> <span class="s1">&#39;&#39;</span>
    <span class="k">return</span> <span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">required</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">_show_directory_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Print service directory list for robot.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object used to get the list of services.</span>
<span class="sd">        as_proto: Boolean to determine whether the directory entries should be printed as full</span>
<span class="sd">            proto definitions or formatted strings.</span>

<span class="sd">    Returns:</span>
<span class="sd">        True</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">entries</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DirectoryClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">list</span><span class="p">()</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">entries</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No services found&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="k">if</span> <span class="n">as_proto</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">entries</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="n">max_name_length</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">entries</span><span class="p">)</span>
    <span class="n">max_type_length</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">type</span><span class="p">)</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">entries</span><span class="p">)</span>
    <span class="n">max_authority_length</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">authority</span><span class="p">)</span> <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">entries</span><span class="p">)</span>

    <span class="n">_format_dir_entry</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;type&#39;</span><span class="p">,</span> <span class="s1">&#39;authority&#39;</span><span class="p">,</span> <span class="s1">&#39;tokens&#39;</span><span class="p">,</span> <span class="n">max_name_length</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span>
                      <span class="n">max_type_length</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span> <span class="n">max_authority_length</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;-&quot;</span> <span class="o">*</span> <span class="p">(</span><span class="mi">20</span> <span class="o">+</span> <span class="n">max_name_length</span> <span class="o">+</span> <span class="n">max_type_length</span> <span class="o">+</span> <span class="n">max_authority_length</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">entry</span> <span class="ow">in</span> <span class="n">entries</span><span class="p">:</span>
        <span class="n">_format_dir_entry</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">authority</span><span class="p">,</span> <span class="n">_token_req_str</span><span class="p">(</span><span class="n">entry</span><span class="p">),</span>
                          <span class="n">max_name_length</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span> <span class="n">max_type_length</span> <span class="o">+</span> <span class="mi">4</span><span class="p">,</span> <span class="n">max_authority_length</span> <span class="o">+</span> <span class="mi">4</span><span class="p">)</span>

    <span class="k">return</span> <span class="kc">True</span>


<span class="k">def</span> <span class="nf">_show_directory_entry</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Print a service directory entry.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object used to get the list of services.</span>
<span class="sd">        service: Name of the service to print.</span>
<span class="sd">        as_proto: Boolean to determine whether the directory entries should be printed as full</span>
<span class="sd">            proto definitions or formatted strings.</span>

<span class="sd">    Returns:</span>
<span class="sd">        True</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">entry</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DirectoryClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_entry</span><span class="p">(</span><span class="n">service</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">as_proto</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">entry</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">_format_dir_entry</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;type&#39;</span><span class="p">,</span> <span class="s1">&#39;authority&#39;</span><span class="p">,</span> <span class="s1">&#39;tokens&#39;</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;-&quot;</span> <span class="o">*</span> <span class="mi">90</span><span class="p">)</span>
        <span class="n">_format_dir_entry</span><span class="p">(</span><span class="n">entry</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">entry</span><span class="o">.</span><span class="n">authority</span><span class="p">,</span> <span class="n">_token_req_str</span><span class="p">(</span><span class="n">entry</span><span class="p">))</span>
    <span class="k">return</span> <span class="kc">True</span>


<div class="viewcode-block" id="DirectoryListCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DirectoryListCommand">[docs]</a><span class="k">class</span> <span class="nc">DirectoryListCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;List all services in the directory.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;list&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;List all services in the directory.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DirectoryListCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">_show_directory_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DirectoryGetCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DirectoryGetCommand">[docs]</a><span class="k">class</span> <span class="nc">DirectoryGetCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get entry for a given service in the directory.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;get&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get entry for a given service in the directory.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DirectoryGetCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;service&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;service name to get entry for&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if NonexistentServiceError is caught, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">_show_directory_entry</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">service</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">NonexistentServiceError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The requested service name &quot;</span><span class="si">{}</span><span class="s1">&quot; does not exist.  Available services:&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">options</span><span class="o">.</span><span class="n">service</span><span class="p">))</span>
            <span class="n">_show_directory_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DirectoryRegisterCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DirectoryRegisterCommand">[docs]</a><span class="k">class</span> <span class="nc">DirectoryRegisterCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Register entry for a service in the directory.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;register&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Register entry for a service in the directory.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DirectoryRegisterCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-name&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;unique name of the service&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-type&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Type of the service, e.g. bosdyn.api.RobotStateService&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-authority&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;authority of the service&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-hostname&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;hostname of the service computer&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-port&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;port the service is running on&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--no-user-token&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;disable requirement for user token&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if DirectoryRegistrationResponseError is caught, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">directory_registration_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span>
            <span class="n">DirectoryRegistrationClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">directory_registration_client</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">service_type</span><span class="p">,</span>
                                                   <span class="n">options</span><span class="o">.</span><span class="n">service_authority</span><span class="p">,</span>
                                                   <span class="n">options</span><span class="o">.</span><span class="n">service_hostname</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">service_port</span><span class="p">,</span>
                                                   <span class="n">user_token_required</span><span class="o">=</span><span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">no_user_token</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">DirectoryRegistrationResponseError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
            <span class="c1"># pylint: disable=no-member</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to register service </span><span class="si">{}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">Response Status: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">,</span>
                <span class="n">bosdyn</span><span class="o">.</span><span class="n">api</span><span class="o">.</span><span class="n">directory_registration_pb2</span><span class="o">.</span><span class="n">RegisterServiceResponse</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span>
                    <span class="n">exc</span><span class="o">.</span><span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">)))</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Successfully registered service </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DirectoryUnregisterCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DirectoryUnregisterCommand">[docs]</a><span class="k">class</span> <span class="nc">DirectoryUnregisterCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Unregister entry for a service in the directory.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;unregister&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Unregister entry for a service in the directory.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DirectoryUnregisterCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-name&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;unique name of the service&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if DirectoryRegistrationResponseError is caught, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">directory_registration_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span>
            <span class="n">DirectoryRegistrationClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">directory_registration_client</span><span class="o">.</span><span class="n">unregister</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">DirectoryRegistrationResponseError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
            <span class="c1"># pylint: disable=no-member</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to unregister service </span><span class="si">{}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">Response Status: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">,</span>
                <span class="n">bosdyn</span><span class="o">.</span><span class="n">api</span><span class="o">.</span><span class="n">directory_registration_pb2</span><span class="o">.</span><span class="n">UnregisterServiceResponse</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span>
                    <span class="n">exc</span><span class="o">.</span><span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">)))</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Successfully unregistered service </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="PayloadCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PayloadCommands">[docs]</a><span class="k">class</span> <span class="nc">PayloadCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands related to the payload and payload registration services.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;payload&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands related to the payload and payload registration services.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PayloadCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
                                              <span class="p">[</span><span class="n">PayloadListCommand</span><span class="p">,</span> <span class="n">PayloadRegisterCommand</span><span class="p">])</span></div>


<span class="k">def</span> <span class="nf">_show_payload_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Print payload list for robot.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object used to get the list of services.</span>
<span class="sd">        as_proto: Boolean to determine whether the payload entries should be printed as full</span>
<span class="sd">            proto definitions or formatted strings.</span>

<span class="sd">    Returns:</span>
<span class="sd">        True</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">payload_protos</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">PayloadClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">list_payloads</span><span class="p">()</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">payload_protos</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No payloads found&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="k">if</span> <span class="n">as_proto</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">payload</span> <span class="ow">in</span> <span class="n">payload_protos</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">payload</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="c1"># Print out the payload name, description, and GUID in columns with set width.</span>
    <span class="n">name_width</span> <span class="o">=</span> <span class="mi">30</span>
    <span class="n">description_width</span> <span class="o">=</span> <span class="mi">60</span>
    <span class="n">guid_width</span> <span class="o">=</span> <span class="mi">36</span>
    <span class="nb">print</span><span class="p">((</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">{:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">name_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">description_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">guid_width</span><span class="p">)</span> <span class="o">+</span>
           <span class="s1">&#39;}&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;Name&#39;</span><span class="p">,</span> <span class="s1">&#39;Description&#39;</span><span class="p">,</span> <span class="s1">&#39;GUID&#39;</span><span class="p">))</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;-&quot;</span> <span class="o">*</span> <span class="p">(</span><span class="mi">5</span> <span class="o">+</span> <span class="n">name_width</span> <span class="o">+</span> <span class="n">description_width</span> <span class="o">+</span> <span class="n">guid_width</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">payload</span> <span class="ow">in</span> <span class="n">payload_protos</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">((</span><span class="s1">&#39;{:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">name_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">description_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">guid_width</span><span class="p">)</span> <span class="o">+</span>
               <span class="s1">&#39;}&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">payload</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">payload</span><span class="o">.</span><span class="n">description</span><span class="p">,</span> <span class="n">payload</span><span class="o">.</span><span class="n">GUID</span><span class="p">))</span>
    <span class="k">return</span> <span class="kc">True</span>


<div class="viewcode-block" id="PayloadListCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PayloadListCommand">[docs]</a><span class="k">class</span> <span class="nc">PayloadListCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;List all payloads registered with the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;list&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;List all payloads registered with the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PayloadListCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">_show_payload_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<span class="k">def</span> <span class="nf">_register_payload</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">guid</span><span class="p">,</span> <span class="n">secret</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Register a payload with the robot.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object used to register the payload.</span>
<span class="sd">        name: The name that will be assigned to the registered payload.</span>
<span class="sd">        guid: The GUID that will be assigned to the registered payload.</span>
<span class="sd">        secret: The secret that the payload will be registered with.</span>
<span class="sd">    Returns:</span>
<span class="sd">        True</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">payload_registration_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span>
        <span class="n">PayloadRegistrationClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
    <span class="n">payload</span> <span class="o">=</span> <span class="n">bosdyn</span><span class="o">.</span><span class="n">api</span><span class="o">.</span><span class="n">payload_pb2</span><span class="o">.</span><span class="n">Payload</span><span class="p">(</span><span class="n">GUID</span><span class="o">=</span><span class="n">guid</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">)</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">payload_registration_client</span><span class="o">.</span><span class="n">register_payload</span><span class="p">(</span><span class="n">payload</span><span class="p">,</span> <span class="n">secret</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">PayloadAlreadyExistsError</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">A payload with this GUID is already registered. Check the robot Admin Console.&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Payload successfully registered with the robot.</span><span class="se">\n</span><span class="s1">&#39;</span>
              <span class="s1">&#39;Before it can be used, the payload must be authorized in the Admin Console.&#39;</span><span class="p">)</span>
    <span class="k">return</span> <span class="kc">True</span>


<div class="viewcode-block" id="PayloadRegisterCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PayloadRegisterCommand">[docs]</a><span class="k">class</span> <span class="nc">PayloadRegisterCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Register a payload with the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;register&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Register a payload with the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PayloadRegisterCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--payload-name&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;name of the payload&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--payload-guid&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;guid of the payload&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--payload-secret&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;secret for the payload&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">_register_payload</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">payload_name</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">payload_guid</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">payload_secret</span><span class="p">)</span></div>


<div class="viewcode-block" id="FaultCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.FaultCommands">[docs]</a><span class="k">class</span> <span class="nc">FaultCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands related to the fault service and robot state service (for fault reading).&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;fault&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands related to the fault service and robot state service (for fault reading).</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">FaultCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
                                            <span class="p">[</span><span class="n">FaultShowCommand</span><span class="p">,</span> <span class="n">FaultWatchCommand</span><span class="p">])</span></div>


<span class="k">def</span> <span class="nf">_show_all_faults</span><span class="p">(</span><span class="n">robot</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Print faults for the robot.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object used to get the list of services.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">robot_state_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">RobotStateClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
    <span class="n">robot_state</span> <span class="o">=</span> <span class="n">robot_state_client</span><span class="o">.</span><span class="n">get_robot_state</span><span class="p">()</span>
    <span class="n">system_fault_state</span> <span class="o">=</span> <span class="n">robot_state</span><span class="o">.</span><span class="n">system_fault_state</span>
    <span class="n">behavior_fault_state</span> <span class="o">=</span> <span class="n">robot_state</span><span class="o">.</span><span class="n">behavior_fault_state</span>
    <span class="n">service_fault_state</span> <span class="o">=</span> <span class="n">robot_state</span><span class="o">.</span><span class="n">service_fault_state</span>

    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">*</span> <span class="mi">80</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">system_fault_state</span><span class="o">.</span><span class="n">faults</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No active system faults.&quot;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">fault</span> <span class="ow">in</span> <span class="n">system_fault_state</span><span class="o">.</span><span class="n">faults</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
<span class="si">{fault.name}</span>
<span class="s1">    Error Message: </span><span class="si">{fault.error_message}</span>
<span class="s1">    Onset Time: </span><span class="si">{timestamp}</span><span class="s1">&#39;&#39;&#39;</span> \
              <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">fault</span><span class="o">=</span><span class="n">fault</span><span class="p">,</span> <span class="n">timestamp</span><span class="o">=</span><span class="n">timestamp_to_datetime</span><span class="p">(</span><span class="n">fault</span><span class="o">.</span><span class="n">onset_timestamp</span><span class="p">)))</span>

    <span class="nb">print</span><span class="p">()</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">behavior_fault_state</span><span class="o">.</span><span class="n">faults</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No active behavior faults.&quot;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">fault</span> <span class="ow">in</span> <span class="n">behavior_fault_state</span><span class="o">.</span><span class="n">faults</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
<span class="si">{cause}</span>
<span class="s1">    Onset Time: </span><span class="si">{timestamp}</span>
<span class="s1">    Clearable: </span><span class="si">{clearable}</span><span class="s1">&#39;&#39;&#39;</span> \
                  <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">cause</span><span class="o">=</span><span class="n">BehaviorFault</span><span class="o">.</span><span class="n">Cause</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="n">fault</span><span class="o">.</span><span class="n">cause</span><span class="p">),</span>
                          <span class="n">timestamp</span><span class="o">=</span><span class="n">timestamp_to_datetime</span><span class="p">(</span><span class="n">fault</span><span class="o">.</span><span class="n">onset_timestamp</span><span class="p">),</span>
                          <span class="n">clearable</span><span class="o">=</span><span class="n">BehaviorFault</span><span class="o">.</span><span class="n">Status</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="n">fault</span><span class="o">.</span><span class="n">status</span><span class="p">)))</span>

    <span class="nb">print</span><span class="p">()</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">service_fault_state</span><span class="o">.</span><span class="n">faults</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No active service faults.&quot;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">fault</span> <span class="ow">in</span> <span class="n">service_fault_state</span><span class="o">.</span><span class="n">faults</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;</span>
<span class="si">{fault.fault_id.fault_name}</span>
<span class="s1">    Service Name: </span><span class="si">{fault.fault_id.service_name}</span>
<span class="s1">    Payload GUID: </span><span class="si">{fault.fault_id.payload_guid}</span>
<span class="s1">    Error Message: </span><span class="si">{fault.error_message}</span>
<span class="s1">    Onset Time: </span><span class="si">{timestamp}</span><span class="s1">&#39;&#39;&#39;</span>\
    <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">fault</span><span class="o">=</span><span class="n">fault</span><span class="p">,</span> <span class="n">timestamp</span><span class="o">=</span><span class="n">timestamp_to_datetime</span><span class="p">(</span><span class="n">fault</span><span class="o">.</span><span class="n">onset_timestamp</span><span class="p">)))</span>


<div class="viewcode-block" id="FaultShowCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.FaultShowCommand">[docs]</a><span class="k">class</span> <span class="nc">FaultShowCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Show all faults currently active in robot state.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;show&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Show all faults currently active in robot state.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">FaultShowCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">_show_all_faults</span><span class="p">(</span><span class="n">robot</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="FaultWatchCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.FaultWatchCommand">[docs]</a><span class="k">class</span> <span class="nc">FaultWatchCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Watch all faults in robot state and print them out.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;watch&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Watch all service faults in robot state and print them out.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">FaultWatchCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Press Ctrl-C or send SIGINT to exit</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
                <span class="n">_show_all_faults</span><span class="p">(</span><span class="n">robot</span><span class="p">)</span>
                <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span>
            <span class="k">pass</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="LogStatusCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.LogStatusCommands">[docs]</a><span class="k">class</span> <span class="nc">LogStatusCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Start, update and terminate experiment logs, start and terminate retro logs and check status of</span>
<span class="sd">    active logs for robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;log-status&#39;</span>
    <span class="n">NEED_AUTHENTICATION</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Interact with logs for robot</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LogStatusCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">subparsers</span><span class="p">,</span>
            <span class="n">command_dict</span><span class="p">,</span>
            <span class="p">[</span>
                <span class="n">GetLogCommand</span><span class="p">,</span>
                <span class="n">GetActiveLogStatusesCommand</span><span class="p">,</span>
                <span class="n">ExperimentLogCommand</span><span class="p">,</span>
                <span class="n">StartRetroLogCommand</span><span class="p">,</span>
                <span class="n">TerminateLogCommand</span><span class="p">,</span>
            <span class="p">])</span></div>


<div class="viewcode-block" id="GetLogCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetLogCommand">[docs]</a><span class="k">class</span> <span class="nc">GetLogCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get log status but log id.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;get&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get log status from robot</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetLogCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;id of log bundle to display&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LogStatusClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_log_status</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">id</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="GetActiveLogStatusesCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetActiveLogStatusesCommand">[docs]</a><span class="k">class</span> <span class="nc">GetActiveLogStatusesCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get active log bundles for robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;active&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Retrieve active log statuses for robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetActiveLogStatusesCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LogStatusClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_active_log_statuses</span><span class="p">()</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_statuses</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="ExperimentLogCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.ExperimentLogCommand">[docs]</a><span class="k">class</span> <span class="nc">ExperimentLogCommand</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Give experiment log commands to robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;experiment&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Start a timed or continuous experiment log.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ExperimentLogCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span> <span class="p">[</span>
            <span class="n">StartTimedExperimentLogCommand</span><span class="p">,</span>
            <span class="n">StartContinuousExperimentLogCommand</span><span class="p">,</span>
        <span class="p">])</span></div>


<div class="viewcode-block" id="StartTimedExperimentLogCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.StartTimedExperimentLogCommand">[docs]</a><span class="k">class</span> <span class="nc">StartTimedExperimentLogCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Start a timed experiment log.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;timed&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Start timed experiment log</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">StartTimedExperimentLogCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;seconds&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;how long should the experiment run?&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LogStatusClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">start_experiment_log</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">seconds</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="StartContinuousExperimentLogCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.StartContinuousExperimentLogCommand">[docs]</a><span class="k">class</span> <span class="nc">StartContinuousExperimentLogCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Start a continuous experiment log.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;continuous&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Start continuous experiment log, defaulted to update keep alive time by 10 seconds every 5 seconds.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">StartContinuousExperimentLogCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-sleep&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;how long should thread sleep before extending&#39;</span><span class="p">)</span>

<div class="viewcode-block" id="StartContinuousExperimentLogCommand.handle_keyboard_interruption"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.StartContinuousExperimentLogCommand.handle_keyboard_interruption">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">handle_keyboard_interruption</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">log_id</span><span class="p">):</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; Received keyboard interruption</span><span class="se">\n\n</span><span class="s2">&quot;</span><span class="p">)</span>
            <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">terminate_log</span><span class="p">(</span><span class="n">log_id</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span>
            <span class="n">client</span><span class="o">.</span><span class="n">terminate_log_async</span><span class="p">(</span><span class="n">log_id</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Log will terminate shortly&quot;</span><span class="p">)</span>
            <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_log_status</span><span class="p">(</span><span class="n">log_id</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LogStatusClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">start_experiment_log</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">sleep</span> <span class="o">*</span> <span class="mi">2</span><span class="p">)</span>
        <span class="n">log_id</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="o">.</span><span class="n">id</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Experiment log id: &quot;</span><span class="p">,</span> <span class="n">log_id</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Use terminate command, press Ctrl-C or send SIGINT to complete log</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
                <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">sleep</span><span class="p">)</span>
                <span class="n">client</span><span class="o">.</span><span class="n">update_experiment</span><span class="p">(</span><span class="n">log_id</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">sleep</span> <span class="o">*</span> <span class="mi">2</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">InactiveLogError</span><span class="p">:</span>
            <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_log_status</span><span class="p">(</span><span class="n">log_id</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">KeyboardInterrupt</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">handle_keyboard_interruption</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">log_id</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="StartRetroLogCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.StartRetroLogCommand">[docs]</a><span class="k">class</span> <span class="nc">StartRetroLogCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Start a retro log.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;retro&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Start a retro log</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">StartRetroLogCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;seconds&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;how long should the retro log run?&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LogStatusClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">start_retro_log</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">seconds</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="TerminateLogCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.TerminateLogCommand">[docs]</a><span class="k">class</span> <span class="nc">TerminateLogCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Terminate log gathering process.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;terminate&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Terminate log on robot</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TerminateLogCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;id of log to terminate&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LogStatusClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">terminate_log</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">id</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">log_status</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>




<div class="viewcode-block" id="RobotIdCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.RobotIdCommand">[docs]</a><span class="k">class</span> <span class="nc">RobotIdCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Show robot-id.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;id&#39;</span>
    <span class="n">NEED_AUTHENTICATION</span> <span class="o">=</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Show robot-id.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">RobotIdCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">proto</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">RobotIdClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_id</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">proto</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="n">nickname</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">if</span> <span class="n">proto</span><span class="o">.</span><span class="n">nickname</span> <span class="ow">and</span> <span class="n">proto</span><span class="o">.</span><span class="n">nickname</span> <span class="o">!=</span> <span class="n">proto</span><span class="o">.</span><span class="n">serial_number</span><span class="p">:</span>
            <span class="n">nickname</span> <span class="o">=</span> <span class="n">proto</span><span class="o">.</span><span class="n">nickname</span>
        <span class="n">release</span> <span class="o">=</span> <span class="n">proto</span><span class="o">.</span><span class="n">software_release</span>
        <span class="n">version</span> <span class="o">=</span> <span class="n">release</span><span class="o">.</span><span class="n">version</span>
        <span class="nb">print</span><span class="p">(</span><span class="sa">u</span><span class="s2">&quot;</span><span class="si">{:20}</span><span class="s2"> </span><span class="si">{:15}</span><span class="s2"> </span><span class="si">{:10}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">)&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">proto</span><span class="o">.</span><span class="n">serial_number</span><span class="p">,</span> <span class="n">proto</span><span class="o">.</span><span class="n">computer_serial_number</span><span class="p">,</span>
                                                  <span class="n">nickname</span><span class="p">,</span> <span class="n">proto</span><span class="o">.</span><span class="n">species</span><span class="p">,</span> <span class="n">proto</span><span class="o">.</span><span class="n">version</span><span class="p">))</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; Software: </span><span class="si">{}</span><span class="s2">.</span><span class="si">{}</span><span class="s2">.</span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">)&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">version</span><span class="o">.</span><span class="n">major_version</span><span class="p">,</span> <span class="n">version</span><span class="o">.</span><span class="n">minor_version</span><span class="p">,</span>
                                                   <span class="n">version</span><span class="o">.</span><span class="n">patch_level</span><span class="p">,</span> <span class="n">release</span><span class="o">.</span><span class="n">changeset</span><span class="p">,</span>
                                                   <span class="n">timestamp_to_datetime</span><span class="p">(</span><span class="n">release</span><span class="o">.</span><span class="n">changeset_date</span><span class="p">)))</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;  Installed: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">timestamp_to_datetime</span><span class="p">(</span><span class="n">release</span><span class="o">.</span><span class="n">install_date</span><span class="p">)))</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DataBufferCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataBufferCommands">[docs]</a><span class="k">class</span> <span class="nc">DataBufferCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands related to the data-buffer service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;log&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands related to the data-buffer service.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataBufferCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
                                                 <span class="p">[</span><span class="n">TextMsgCommand</span><span class="p">,</span> <span class="n">OperatorCommentCommand</span><span class="p">])</span></div>


<div class="viewcode-block" id="TextMsgCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.TextMsgCommand">[docs]</a><span class="k">class</span> <span class="nc">TextMsgCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Send a text-message to the data buffer to be logged.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;textmsg&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Send a text-message to the data buffer to be logged.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TextMsgCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--timestamp&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;achieve time-sync and send timestamp&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--tag&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Tag for message&#39;</span><span class="p">)</span>
        <span class="n">parser_log_level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_mutually_exclusive_group</span><span class="p">()</span>
        <span class="n">parser_log_level</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--debug&#39;</span><span class="p">,</span> <span class="s1">&#39;-D&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                      <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Log at debug-level&#39;</span><span class="p">)</span>
        <span class="n">parser_log_level</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--info&#39;</span><span class="p">,</span> <span class="s1">&#39;-I&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Log at info-level&#39;</span><span class="p">)</span>
        <span class="n">parser_log_level</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--warn&#39;</span><span class="p">,</span> <span class="s1">&#39;-W&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Log at warn-level&#39;</span><span class="p">)</span>
        <span class="n">parser_log_level</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--error&#39;</span><span class="p">,</span> <span class="s1">&#39;-E&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                      <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Log at error-level&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Message to log&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if TimeSyncError is caught, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">robot_timestamp</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">timestamp</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">robot_timestamp</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">time_sync</span><span class="o">.</span><span class="n">robot_timestamp_from_local_secs</span><span class="p">(</span>
                    <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="n">timesync_timeout_sec</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
            <span class="k">except</span> <span class="n">TimeSyncError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to send message with timestamp: </span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">err</span><span class="p">))</span>
                <span class="k">return</span> <span class="kc">False</span>
        <span class="n">msg_proto</span> <span class="o">=</span> <span class="n">TextMessage</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">message</span><span class="p">,</span> <span class="n">timestamp</span><span class="o">=</span><span class="n">robot_timestamp</span><span class="p">)</span>
        <span class="c1"># pylint: disable=no-member</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">debug</span><span class="p">:</span>
            <span class="n">msg_proto</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">TextMessage</span><span class="o">.</span><span class="n">LEVEL_DEBUG</span>
        <span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">warn</span><span class="p">:</span>
            <span class="n">msg_proto</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">TextMessage</span><span class="o">.</span><span class="n">LEVEL_WARN</span>
        <span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">error</span><span class="p">:</span>
            <span class="n">msg_proto</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">TextMessage</span><span class="o">.</span><span class="n">LEVEL_ERROR</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">msg_proto</span><span class="o">.</span><span class="n">level</span> <span class="o">=</span> <span class="n">TextMessage</span><span class="o">.</span><span class="n">LEVEL_INFO</span>

        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">tag</span><span class="p">:</span>
            <span class="n">msg_proto</span><span class="o">.</span><span class="n">tag</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">tag</span>

        <span class="n">data_buffer_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DataBufferClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">data_buffer_client</span><span class="o">.</span><span class="n">add_text_messages</span><span class="p">([</span><span class="n">msg_proto</span><span class="p">])</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="OperatorCommentCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.OperatorCommentCommand">[docs]</a><span class="k">class</span> <span class="nc">OperatorCommentCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Send an operator comment to the robot to be logged.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;comment&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Send an operator comment to the robot to be logged.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">OperatorCommentCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--timestamp&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;achieve time-sync and send timestamp&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;operator comment text&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if TimeSyncError is caught, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client_timestamp</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">timestamp</span><span class="p">:</span>
            <span class="n">client_timestamp</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">robot</span><span class="o">.</span><span class="n">time_sync</span><span class="o">.</span><span class="n">wait_for_sync</span><span class="p">(</span><span class="n">timeout_sec</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
            <span class="k">except</span> <span class="n">TimeSyncError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to get timesync for setting comment timestamp: </span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">err</span><span class="p">))</span>
                <span class="k">return</span> <span class="kc">False</span>
        <span class="n">robot</span><span class="o">.</span><span class="n">operator_comment</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">message</span><span class="p">,</span> <span class="n">timestamp_secs</span><span class="o">=</span><span class="n">client_timestamp</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DataServiceCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataServiceCommands">[docs]</a><span class="k">class</span> <span class="nc">DataServiceCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands for querying the data-service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;data&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands for querying the data-service</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataServiceCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
            <span class="p">[</span><span class="n">GetDataBufferCommentsCommand</span><span class="p">,</span> <span class="n">GetDataBufferEventsCommand</span><span class="p">,</span> <span class="n">GetDataBufferStatusCommand</span><span class="p">])</span></div>


<div class="viewcode-block" id="GetDataBufferEventsCommentsCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferEventsCommentsCommand">[docs]</a><span class="k">class</span> <span class="nc">GetDataBufferEventsCommentsCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Parent class for commands grabbing operator comment and events.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get operator comments from the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetDataBufferEventsCommentsCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print in proto format&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span>
            <span class="s1">&#39;-T&#39;</span><span class="p">,</span> <span class="s1">&#39;--timespan&#39;</span><span class="p">,</span>
            <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Time span (default all).  &quot;1h&quot; (last hour), &quot;10m-5m&quot; (from 10 to 5 minutes ago).&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-R&#39;</span><span class="p">,</span> <span class="s1">&#39;--robot-time&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Specified timespan is in robot time&#39;</span><span class="p">)</span>

    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
        <span class="k">pass</span>

<div class="viewcode-block" id="GetDataBufferEventsCommentsCommand.pretty_print"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferEventsCommentsCommand.pretty_print">[docs]</a>    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">pretty_print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Print output of request in a human-friendly way.&quot;&quot;&quot;</span></div>

    <span class="k">def</span> <span class="nf">_get_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request_spec</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">get_values_fn</span><span class="p">):</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DataServiceClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">timespan</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">robot_time</span><span class="p">:</span>
                <span class="n">time_sync_endpoint</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">time_sync_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">TimeSyncClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
                <span class="n">time_sync_endpoint</span> <span class="o">=</span> <span class="n">TimeSyncEndpoint</span><span class="p">(</span><span class="n">time_sync_client</span><span class="p">)</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="n">time_sync_endpoint</span><span class="o">.</span><span class="n">establish_timesync</span><span class="p">():</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to get timesync for requesting comments.&quot;</span><span class="p">)</span>
                    <span class="k">return</span> <span class="kc">False</span>
            <span class="n">time_range</span> <span class="o">=</span> <span class="n">timespec_to_robot_timespan</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">timespan</span><span class="p">,</span> <span class="n">time_sync_endpoint</span><span class="p">)</span>
            <span class="c1"># pylint: disable=no-member</span>
            <span class="n">request_spec</span><span class="o">.</span><span class="n">time_range</span><span class="o">.</span><span class="n">CopyFrom</span><span class="p">(</span><span class="n">time_range</span><span class="p">)</span>
        <span class="n">values</span> <span class="o">=</span> <span class="n">get_values_fn</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">get_events_comments</span><span class="p">(</span><span class="n">request_spec</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">values</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pretty_print</span><span class="p">(</span><span class="n">values</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="GetDataBufferCommentsCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferCommentsCommand">[docs]</a><span class="k">class</span> <span class="nc">GetDataBufferCommentsCommand</span><span class="p">(</span><span class="n">GetDataBufferEventsCommentsCommand</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get operator comments from the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;comments&#39;</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">request_spec</span> <span class="o">=</span> <span class="n">EventsCommentsSpec</span><span class="p">(</span><span class="n">comments</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="k">def</span> <span class="nf">_get_comments</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">events_comments</span><span class="o">.</span><span class="n">operator_comments</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_result</span><span class="p">(</span><span class="n">request_spec</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">_get_comments</span><span class="p">)</span>

<div class="viewcode-block" id="GetDataBufferCommentsCommand.pretty_print"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferCommentsCommand.pretty_print">[docs]</a>    <span class="k">def</span> <span class="nf">pretty_print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">):</span>  <span class="c1"># pylint: disable=no-self-use</span>
        <span class="n">last_date_shown</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span>
            <span class="n">dtm</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">comment</span><span class="o">.</span><span class="n">timestamp</span><span class="o">.</span><span class="n">seconds</span> <span class="o">+</span>
                                                  <span class="n">comment</span><span class="o">.</span><span class="n">timestamp</span><span class="o">.</span><span class="n">seconds</span> <span class="o">*</span> <span class="mf">1e-9</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">dtm</span><span class="o">.</span><span class="n">date</span><span class="p">()</span> <span class="o">!=</span> <span class="n">last_date_shown</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">[</span><span class="si">{}</span><span class="s2">]&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">dtm</span><span class="o">.</span><span class="n">date</span><span class="p">()))</span>
                <span class="n">last_date_shown</span> <span class="o">=</span> <span class="n">dtm</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2">  </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">dtm</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="n">comment</span><span class="o">.</span><span class="n">message</span><span class="o">.</span><span class="n">strip</span><span class="p">()))</span></div></div>


<div class="viewcode-block" id="GetDataBufferEventsCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferEventsCommand">[docs]</a><span class="k">class</span> <span class="nc">GetDataBufferEventsCommand</span><span class="p">(</span><span class="n">GetDataBufferEventsCommentsCommand</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get events from the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;events&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get operator comments from the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetDataBufferEventsCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--type&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;query for only the given event-type&#39;</span><span class="p">)</span>
        <span class="c1"># pylint: disable=no-member</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span>
            <span class="s1">&#39;--level&#39;</span><span class="p">,</span>
            <span class="n">choices</span><span class="o">=</span><span class="n">Event</span><span class="o">.</span><span class="n">Level</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">1</span><span class="p">:],</span>  <span class="c1"># slice skips UNSET</span>
            <span class="n">help</span><span class="o">=</span><span class="s1">&#39;limit level to this and above&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">request_spec</span> <span class="o">=</span> <span class="n">EventsCommentsSpec</span><span class="p">()</span>
        <span class="n">event_spec</span> <span class="o">=</span> <span class="n">request_spec</span><span class="o">.</span><span class="n">events</span><span class="o">.</span><span class="n">add</span><span class="p">()</span>  <span class="c1"># pylint: disable=no-member</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">type</span><span class="p">:</span>
            <span class="n">event_spec</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">type</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">level</span><span class="p">:</span>
            <span class="n">event_spec</span><span class="o">.</span><span class="n">level</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">Event</span><span class="o">.</span><span class="n">Level</span><span class="o">.</span><span class="n">Value</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">level</span><span class="p">)</span>  <span class="c1"># pylint: disable=no-member</span>

        <span class="k">def</span> <span class="nf">_get_events</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">response</span><span class="o">.</span><span class="n">events_comments</span><span class="o">.</span><span class="n">events</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_result</span><span class="p">(</span><span class="n">request_spec</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">_get_events</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_level_name</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
        <span class="n">prefix</span> <span class="o">=</span> <span class="s1">&#39;LEVEL_&#39;</span>
        <span class="c1"># pylint: disable=no-member</span>
        <span class="n">name</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">Level</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">level</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">prefix</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">name</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">prefix</span><span class="p">):]</span>
        <span class="k">return</span> <span class="n">name</span>

<div class="viewcode-block" id="GetDataBufferEventsCommand.pretty_print"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferEventsCommand.pretty_print">[docs]</a>    <span class="k">def</span> <span class="nf">pretty_print</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">):</span>  <span class="c1"># pylint: disable=no-self-use</span>
        <span class="n">last_date_shown</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span>
            <span class="n">start_secs</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">start_time</span><span class="o">.</span><span class="n">seconds</span> <span class="o">+</span> <span class="n">event</span><span class="o">.</span><span class="n">start_time</span><span class="o">.</span><span class="n">seconds</span> <span class="o">*</span> <span class="mf">1e-9</span>
            <span class="n">start_dt</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">start_secs</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">start_dt</span><span class="o">.</span><span class="n">date</span><span class="p">()</span> <span class="o">!=</span> <span class="n">last_date_shown</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">[</span><span class="si">{}</span><span class="s2">]&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">start_dt</span><span class="o">.</span><span class="n">date</span><span class="p">()))</span>
                <span class="n">last_date_shown</span> <span class="o">=</span> <span class="n">start_dt</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">end_time</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">end_time</span> <span class="o">!=</span> <span class="n">event</span><span class="o">.</span><span class="n">start_time</span><span class="p">:</span>
                <span class="n">end_secs</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">end_time</span><span class="o">.</span><span class="n">seconds</span> <span class="o">+</span> <span class="n">event</span><span class="o">.</span><span class="n">end_time</span><span class="o">.</span><span class="n">seconds</span> <span class="o">*</span> <span class="mf">1e-9</span>
                <span class="n">end_dt</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">end_secs</span><span class="p">)</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2">-</span><span class="si">{}</span><span class="s2"> (END) (</span><span class="si">{:16}</span><span class="s2">) </span><span class="si">{:16}</span><span class="s2">  </span><span class="si">{:16}</span><span class="s2"> &lt;</span><span class="si">{}</span><span class="s2">&gt; &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">start_dt</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="n">end_dt</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="n">end_secs</span> <span class="o">-</span> <span class="n">start_secs</span><span class="p">,</span> <span class="n">event</span><span class="o">.</span><span class="n">type</span><span class="p">,</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_level_name</span><span class="p">(</span><span class="n">event</span><span class="p">),</span> <span class="n">event</span><span class="o">.</span><span class="n">source</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">timing</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span> <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">end_time</span> <span class="k">else</span> <span class="s1">&#39;(START)&#39;</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> </span><span class="si">{:16}</span><span class="s2">  </span><span class="si">{:16}</span><span class="s2">  &lt;</span><span class="si">{}</span><span class="s2">&gt; &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">start_dt</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="n">timing</span><span class="p">,</span> <span class="n">event</span><span class="o">.</span><span class="n">type</span><span class="p">,</span>
                                                          <span class="bp">self</span><span class="o">.</span><span class="n">_level_name</span><span class="p">(</span><span class="n">event</span><span class="p">),</span> <span class="n">event</span><span class="o">.</span><span class="n">source</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">description</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\t</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">description</span><span class="p">))</span></div></div>


<div class="viewcode-block" id="GetDataBufferStatusCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetDataBufferStatusCommand">[docs]</a><span class="k">class</span> <span class="nc">GetDataBufferStatusCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get status of data-buffer on robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;status&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get status of data-buffer on robot</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetDataBufferStatusCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--get-blob-specs&#39;</span><span class="p">,</span> <span class="s1">&#39;-B&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;get list of channel/msgtype/source combinations&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DataServiceClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">get_data_buffer_status</span><span class="p">(</span><span class="n">get_blob_specs</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">get_blob_specs</span><span class="p">))</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="RobotStateCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.RobotStateCommands">[docs]</a><span class="k">class</span> <span class="nc">RobotStateCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands for querying robot state.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;state&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands for querying robot state.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">RobotStateCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
            <span class="p">[</span><span class="n">FullStateCommand</span><span class="p">,</span> <span class="n">HardwareConfigurationCommand</span><span class="p">,</span> <span class="n">MetricsCommand</span><span class="p">,</span> <span class="n">RobotModel</span><span class="p">])</span></div>


<div class="viewcode-block" id="FullStateCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.FullStateCommand">[docs]</a><span class="k">class</span> <span class="nc">FullStateCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Show robot state.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;full&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Show robot state.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">FullStateCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command; prints RobotState proto.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">proto</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">RobotStateClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_robot_state</span><span class="p">()</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">proto</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="HardwareConfigurationCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.HardwareConfigurationCommand">[docs]</a><span class="k">class</span> <span class="nc">HardwareConfigurationCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Show robot hardware configuration.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;hardware&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Show robot hardware configuration.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">HardwareConfigurationCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command; prints HardwareConfiguration proto.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">proto</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span>
            <span class="n">RobotStateClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_robot_hardware_configuration</span><span class="p">()</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">proto</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="RobotModel"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.RobotModel">[docs]</a><span class="k">class</span> <span class="nc">RobotModel</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Write robot URDF and mesh to local files.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;model&#39;</span>
    <span class="n">NEED_AUTHENTICATION</span> <span class="o">=</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Write robot URDF and mesh to local files.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">RobotModel</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--outdir&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s1">&#39;Model_Files&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;directory into which to save the files&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">robot_state_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">RobotStateClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">hardware</span> <span class="o">=</span> <span class="n">robot_state_client</span><span class="o">.</span><span class="n">get_robot_hardware_configuration</span><span class="p">()</span>

        <span class="c1"># Write files in user-specified directory, or use default name</span>
        <span class="n">model_directory</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">outdir</span>

        <span class="c1"># Make the directory, if it does not already exist</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">model_directory</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
            <span class="k">pass</span>

        <span class="c1"># Write each link model to its own file</span>
        <span class="k">for</span> <span class="n">link</span> <span class="ow">in</span> <span class="n">hardware</span><span class="o">.</span><span class="n">skeleton</span><span class="o">.</span><span class="n">links</span><span class="p">:</span>
            <span class="c1"># Request a Skeleton.Link.ObjModel from the robot for link.name and write it to a file</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">obj_model_proto</span> <span class="o">=</span> <span class="n">robot_state_client</span><span class="o">.</span><span class="n">get_robot_link_model</span><span class="p">(</span><span class="n">link</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
            <span class="k">except</span> <span class="n">InvalidRequestError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="n">err</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">)</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; Name of link: &quot;</span> <span class="o">+</span> <span class="n">link</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
                <span class="k">continue</span>

            <span class="c1"># If file_name is empty, ignore</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">obj_model_proto</span><span class="o">.</span><span class="n">file_name</span><span class="p">:</span>
                <span class="k">continue</span>

            <span class="c1"># Write to a file, ignoring the robot path</span>
            <span class="n">sub_path</span> <span class="o">=</span> <span class="s1">&#39;/&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">obj_model_proto</span><span class="o">.</span><span class="n">file_name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>  <span class="c1"># robot defined path</span>
            <span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">model_directory</span><span class="p">,</span> <span class="n">sub_path</span><span class="p">)</span>  <span class="c1"># local path + robot path</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
                <span class="k">pass</span>

            <span class="n">path_and_name</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">obj_model_proto</span><span class="o">.</span><span class="n">file_name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path_and_name</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">obj_file</span><span class="p">:</span>
                <span class="n">obj_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">obj_model_proto</span><span class="o">.</span><span class="n">file_contents</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Link file written to &#39;</span> <span class="o">+</span> <span class="n">path_and_name</span><span class="p">)</span>

        <span class="c1"># Write the corresponding urdf file inside the link directory</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">model_directory</span><span class="p">,</span> <span class="s2">&quot;model.urdf&quot;</span><span class="p">),</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">urdf_file</span><span class="p">:</span>
            <span class="n">urdf_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">hardware</span><span class="o">.</span><span class="n">skeleton</span><span class="o">.</span><span class="n">urdf</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;URDF file written to &#39;</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">model_directory</span><span class="p">,</span> <span class="s2">&quot;model.urdf&quot;</span><span class="p">))</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="MetricsCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.MetricsCommand">[docs]</a><span class="k">class</span> <span class="nc">MetricsCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Show metrics (runtime, etc...).&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;metrics&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Show metrics (runtime, etc...).</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">MetricsCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print metrics in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">proto</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">RobotStateClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_robot_metrics</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">proto</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">for</span> <span class="n">metric</span> <span class="ow">in</span> <span class="n">proto</span><span class="o">.</span><span class="n">metrics</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_format_metric</span><span class="p">(</span><span class="n">metric</span><span class="p">))</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_secs_to_hms</span><span class="p">(</span><span class="n">seconds</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Converts seconds to hours:minutes:seconds string.</span>

<span class="sd">        Args:</span>
<span class="sd">            seconds: Seconds to convert.</span>

<span class="sd">        Returns:</span>
<span class="sd">            String in the format hours:MM:SS.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">isecs</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">seconds</span><span class="p">)</span>
        <span class="n">seconds</span> <span class="o">=</span> <span class="n">isecs</span> <span class="o">%</span> <span class="mi">60</span>
        <span class="n">minutes</span> <span class="o">=</span> <span class="p">(</span><span class="n">isecs</span> <span class="o">//</span> <span class="mi">60</span><span class="p">)</span> <span class="o">%</span> <span class="mi">60</span>
        <span class="n">hours</span> <span class="o">=</span> <span class="n">isecs</span> <span class="o">//</span> <span class="mi">3600</span>
        <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:d}</span><span class="s1">:</span><span class="si">{:02d}</span><span class="s1">:</span><span class="si">{:02d}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">hours</span><span class="p">,</span> <span class="n">minutes</span><span class="p">,</span> <span class="n">seconds</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_distance_str</span><span class="p">(</span><span class="n">meters</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Converts distance to human-readable string.</span>

<span class="sd">        Args:</span>
<span class="sd">            meters: Distance in meters to convert.</span>

<span class="sd">        Returns:</span>
<span class="sd">            String with meters with two digit precision if distance is less than 1000 meters, or</span>
<span class="sd">            kilometers with two digit precision otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">meters</span> <span class="o">&lt;</span> <span class="mi">1000</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:.2f}</span><span class="s1"> m&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">meters</span><span class="p">)</span>
        <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:.2f}</span><span class="s1"> km&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">meters</span><span class="p">)</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_timestamp_str</span><span class="p">(</span><span class="n">timestamp</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Converts a timestamp to a human-readable string.</span>

<span class="sd">        Args:</span>
<span class="sd">            timestamp: Protobuf timestamp to convert</span>

<span class="sd">        Returns:</span>
<span class="sd">             Timestamp string in ISO 8601 format</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># The json format of a timestamp is a string that looks like &#39;&quot;2022-01-12T21:56:05Z&quot;&#39;,</span>
        <span class="c1"># so we strip off the outer quotes and return that.</span>
        <span class="k">return</span> <span class="n">json_format</span><span class="o">.</span><span class="n">MessageToJson</span><span class="p">(</span><span class="n">timestamp</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">&#39;&quot;&#39;</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_format_metric</span><span class="p">(</span><span class="n">metric</span><span class="p">):</span>  <span class="c1"># pylint: disable=too-many-return-statements</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Convert metric input to human-readable string.</span>

<span class="sd">        Args:</span>
<span class="sd">            metric: Input metric object to convert.</span>

<span class="sd">        Returns:</span>
<span class="sd">            String in the format: Label float_value units.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">field</span> <span class="o">=</span> <span class="n">metric</span><span class="o">.</span><span class="n">WhichOneof</span><span class="p">(</span><span class="s1">&#39;values&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">field</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:20}</span><span class="s1"> missing value&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">metric</span><span class="o">.</span><span class="n">label</span><span class="p">)</span>
        <span class="n">value</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">metric</span><span class="p">,</span> <span class="n">field</span><span class="p">)</span>

        <span class="c1"># Special case formatting</span>
        <span class="k">if</span> <span class="n">field</span> <span class="o">==</span> <span class="s1">&#39;duration&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:20}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">metric</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">MetricsCommand</span><span class="o">.</span><span class="n">_secs_to_hms</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">seconds</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">field</span> <span class="o">==</span> <span class="s1">&#39;timestamp&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:20}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">metric</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">MetricsCommand</span><span class="o">.</span><span class="n">_timestamp_str</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">field</span> <span class="o">==</span> <span class="s1">&#39;float_value&#39;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">metric</span><span class="o">.</span><span class="n">units</span> <span class="o">==</span> <span class="s1">&#39;m&#39;</span><span class="p">:</span>
                <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:20}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">metric</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">MetricsCommand</span><span class="o">.</span><span class="n">_distance_str</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:20}</span><span class="s1"> </span><span class="si">{:.2f}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">metric</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">metric</span><span class="o">.</span><span class="n">units</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Default formatting</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{:20}</span><span class="s1"> </span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">metric</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">metric</span><span class="o">.</span><span class="n">units</span><span class="p">)</span></div>


<div class="viewcode-block" id="TimeSyncCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.TimeSyncCommand">[docs]</a><span class="k">class</span> <span class="nc">TimeSyncCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Find clock difference between this and the robot clock.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;time-sync&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Find clock difference between this and the robot clock.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">TimeSyncCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if timesync cannot be established, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">endpoint</span> <span class="o">=</span> <span class="n">TimeSyncEndpoint</span><span class="p">(</span><span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">TimeSyncClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">))</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">endpoint</span><span class="o">.</span><span class="n">establish_timesync</span><span class="p">(</span><span class="n">break_on_success</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to achieve time sync&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">False</span>

        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">endpoint</span><span class="o">.</span><span class="n">response</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>

        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;GRPC round-trip time: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">duration_str</span><span class="p">(</span><span class="n">endpoint</span><span class="o">.</span><span class="n">round_trip_time</span><span class="p">)))</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Local time to robot time: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">duration_str</span><span class="p">(</span><span class="n">endpoint</span><span class="o">.</span><span class="n">clock_skew</span><span class="p">)))</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="LicenseCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.LicenseCommand">[docs]</a><span class="k">class</span> <span class="nc">LicenseCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Show installed license.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s2">&quot;license&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LicenseCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-f&#39;</span><span class="p">,</span> <span class="s1">&#39;--feature-codes&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;+&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Optional feature list for GetFeatureEnabled API.&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">license_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LicenseClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_get_license_info</span><span class="p">(</span><span class="n">license_client</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_get_feature_enabled</span><span class="p">(</span><span class="n">license_client</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="k">def</span> <span class="nf">_get_license_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">license_client</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
        <span class="n">license_info</span> <span class="o">=</span> <span class="n">license_client</span><span class="o">.</span><span class="n">get_license_info</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">license_info</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">license_info</span><span class="p">))</span>

    <span class="k">def</span> <span class="nf">_get_feature_enabled</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">license_client</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">feature_codes</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">feature_codes</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">return</span>

        <span class="n">feature_enabled</span> <span class="o">=</span> <span class="n">license_client</span><span class="o">.</span><span class="n">get_feature_enabled</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">feature_codes</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">feature</span> <span class="ow">in</span> <span class="n">feature_enabled</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">feature_enabled</span><span class="p">[</span><span class="n">feature</span><span class="p">]:</span>
                <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Feature </span><span class="si">{</span><span class="n">feature</span><span class="si">}</span><span class="s2"> is enabled.&quot;</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Feature </span><span class="si">{</span><span class="n">feature</span><span class="si">}</span><span class="s2"> is not enabled.&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="LeaseCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.LeaseCommands">[docs]</a><span class="k">class</span> <span class="nc">LeaseCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands related to the lease service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;lease&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands related to the lease service.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LeaseCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span> <span class="p">[</span><span class="n">LeaseListCommand</span><span class="p">])</span></div>


<div class="viewcode-block" id="LeaseListCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.LeaseListCommand">[docs]</a><span class="k">class</span> <span class="nc">LeaseListCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;List all leases.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;list&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;List all leases.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LeaseListCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">lease_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LeaseClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">resources</span> <span class="o">=</span> <span class="n">lease_client</span><span class="o">.</span><span class="n">list_leases</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">resources</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">for</span> <span class="n">resource</span> <span class="ow">in</span> <span class="n">resources</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_format_lease_resource</span><span class="p">(</span><span class="n">resource</span><span class="p">))</span>
        <span class="k">return</span> <span class="kc">True</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_format_lease_resource</span><span class="p">(</span><span class="n">resource</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">resource</span><span class="p">)</span></div>


<div class="viewcode-block" id="EstopCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.EstopCommands">[docs]</a><span class="k">class</span> <span class="nc">EstopCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands for interacting with robot estop service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;estop&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands for interacting with robot estop service.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">EstopCommands</span><span class="p">,</span>
              <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
                             <span class="p">[</span><span class="n">BecomeEstopCommand</span><span class="p">,</span> <span class="n">GetEstopConfigCommand</span><span class="p">,</span> <span class="n">GetEstopStatusCommand</span><span class="p">])</span></div>


<div class="viewcode-block" id="GetEstopConfigCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetEstopConfigCommand">[docs]</a><span class="k">class</span> <span class="nc">GetEstopConfigCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get estop config of estop service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;config&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Call EstopService GetEstopConfig RPC.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetEstopConfigCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">EstopClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">config</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_config</span><span class="p">()</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">config</span><span class="p">)</span></div>


<div class="viewcode-block" id="GetEstopStatusCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetEstopStatusCommand">[docs]</a><span class="k">class</span> <span class="nc">GetEstopStatusCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get estop status of estop service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;status&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Call EstopService GetEstopSystemStatus RPC.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetEstopStatusCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">EstopClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">status</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_status</span><span class="p">()</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">status</span><span class="p">)</span></div>


<div class="viewcode-block" id="BecomeEstopCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.BecomeEstopCommand">[docs]</a><span class="k">class</span> <span class="nc">BecomeEstopCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Grab and hold estop until Ctl-C.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;become-estop&#39;</span>

    <span class="n">_RPC_PRINT_CHOICES</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;timestamp&#39;</span><span class="p">,</span> <span class="s1">&#39;full&#39;</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Grab and hold estop until Ctl-C.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">BecomeEstopCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--timeout&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;EStop timeout (seconds)&#39;</span><span class="p">,</span>
                                  <span class="n">default</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--rpc-print&#39;</span><span class="p">,</span> <span class="n">choices</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_RPC_PRINT_CHOICES</span><span class="p">,</span>
                                  <span class="n">default</span><span class="o">=</span><span class="s1">&#39;timestamp&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;How much of the request/response messages to print&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Get a client to the estop service.</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">EstopClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>

        <span class="c1"># If we&#39;d only like to print timestamps of messages, change the client&#39;s callbacks that</span>
        <span class="c1"># convert messages to string.</span>

        <span class="k">def</span> <span class="nf">_timestamp_fmt_request</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
            <span class="k">return</span> <span class="s1">&#39;(request timestamp: </span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">header</span><span class="o">.</span><span class="n">request_timestamp</span><span class="o">.</span><span class="n">ToSeconds</span><span class="p">())</span>

        <span class="k">def</span> <span class="nf">_timestamp_fmt_response</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
            <span class="k">return</span> <span class="s1">&#39;(response timestamp: </span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">header</span><span class="o">.</span><span class="n">response_timestamp</span><span class="o">.</span><span class="n">ToSeconds</span><span class="p">())</span>

        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">rpc_print</span> <span class="o">==</span> <span class="s1">&#39;timestamp&#39;</span><span class="p">:</span>
            <span class="n">client</span><span class="o">.</span><span class="n">request_trim_for_log</span> <span class="o">=</span> <span class="n">_timestamp_fmt_request</span>
            <span class="n">client</span><span class="o">.</span><span class="n">response_trim_for_log</span> <span class="o">=</span> <span class="n">_timestamp_fmt_response</span>

        <span class="c1"># Create the endpoint to the robot estop system.</span>
        <span class="c1"># Timeout should be chosen to balance safety considerations with expected service latency.</span>
        <span class="c1"># See the estop documentation for details.</span>
        <span class="n">endpoint</span> <span class="o">=</span> <span class="n">EstopEndpoint</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="sa">f</span><span class="s2">&quot;command-line-</span><span class="si">{</span><span class="n">socket</span><span class="o">.</span><span class="n">gethostname</span><span class="p">()</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">timeout</span><span class="p">)</span>
        <span class="c1"># Have this endpoint to set up the robot&#39;s estop system such that it is the sole estop.</span>
        <span class="c1"># See the function&#39;s docstring and the estop documentation for details.</span>
        <span class="n">endpoint</span><span class="o">.</span><span class="n">force_simple_setup</span><span class="p">()</span>
        <span class="c1"># Create the helper class that does periodic check-ins. This also starts the checking-in.</span>
        <span class="n">exit_signal</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>

        <span class="c1"># Define a function to call on SIGINT that asserts an estop and cleanly shuts down.</span>
        <span class="k">def</span> <span class="nf">sigint_handler</span><span class="p">(</span><span class="n">sig</span><span class="p">,</span> <span class="n">frame</span><span class="p">):</span>
<span class="w">            </span><span class="sd">&quot;&quot;&quot;Cleanly shut down the application on interrupt.&quot;&quot;&quot;</span>
            <span class="c1">#pylint: disable=unused-argument</span>
            <span class="c1"># Signal that we want to exit the program.</span>
            <span class="n">exit_signal</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>

        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Press Ctrl-C or send SIGINT to exit&#39;</span><span class="p">)</span>
        <span class="c1"># Install our signal handler function.</span>
        <span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span><span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">,</span> <span class="n">sigint_handler</span><span class="p">)</span>

        <span class="k">with</span> <span class="n">EstopKeepAlive</span><span class="p">(</span><span class="n">endpoint</span><span class="p">)</span> <span class="k">as</span> <span class="n">keep_alive</span><span class="p">:</span>
            <span class="c1"># Now we wait. The thread in EstopKeepAlive will continue sending messages to the estop</span>
            <span class="c1"># service on its own.</span>
            <span class="k">while</span> <span class="ow">not</span> <span class="n">exit_signal</span><span class="o">.</span><span class="n">wait</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>
                <span class="k">pass</span>
            <span class="c1"># EStop the robot.</span>
            <span class="n">keep_alive</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
            <span class="c1"># The keep_alive object&#39;s exit() function will shut down the thread.</span>

        <span class="c1"># This will let another endpoint fill our role, if they want to use the current</span>
        <span class="c1"># configuration. For details, see the estop documentation.</span>
        <span class="n">endpoint</span><span class="o">.</span><span class="n">deregister</span><span class="p">()</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="OldBecomeEstopCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.OldBecomeEstopCommand">[docs]</a><span class="k">class</span> <span class="nc">OldBecomeEstopCommand</span><span class="p">(</span><span class="n">BecomeEstopCommand</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Old version of BecomeEstopCommand.&quot;&quot;&quot;</span>

<div class="viewcode-block" id="OldBecomeEstopCommand.run"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.OldBecomeEstopCommand.run">[docs]</a>    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;DEPRECATION WARNING: This command is now &quot;bosdyn.client estop become-estop&quot;&#39;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">BecomeEstopCommand</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="ImageCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.ImageCommands">[docs]</a><span class="k">class</span> <span class="nc">ImageCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands for querying images.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;image&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands for querying images.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ImageCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
                                            <span class="p">[</span><span class="n">ListImageSourcesCommand</span><span class="p">,</span> <span class="n">GetImageCommand</span><span class="p">])</span></div>


<span class="k">def</span> <span class="nf">_show_image_sources_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">service_name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Print available image sources.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object on which to run the command.</span>
<span class="sd">        as_proto: Boolean to determine whether to print the full proto message, or a human-readable</span>
<span class="sd">            string in the format: source_name (rows x cols)</span>

<span class="sd">    Returns:</span>
<span class="sd">        True.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">service_name</span> <span class="o">=</span> <span class="n">service_name</span> <span class="ow">or</span> <span class="n">ImageClient</span><span class="o">.</span><span class="n">default_service_name</span>
    <span class="n">proto</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">service_name</span><span class="p">)</span><span class="o">.</span><span class="n">list_image_sources</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">as_proto</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">proto</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">image_source</span> <span class="ow">in</span> <span class="n">proto</span><span class="p">:</span>
            <span class="n">image_formats</span> <span class="o">=</span> <span class="p">[</span><span class="n">image_pb2</span><span class="o">.</span><span class="n">Image</span><span class="o">.</span><span class="n">Format</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="n">i</span><span class="p">)[</span><span class="mi">7</span><span class="p">:]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">image_source</span><span class="o">.</span><span class="n">image_formats</span><span class="p">]</span>
            <span class="n">pixel_formats</span> <span class="o">=</span> <span class="p">[</span>
                <span class="n">image_pb2</span><span class="o">.</span><span class="n">Image</span><span class="o">.</span><span class="n">PixelFormat</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="n">i</span><span class="p">)[</span><span class="mi">13</span><span class="p">:]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">image_source</span><span class="o">.</span><span class="n">pixel_formats</span>
            <span class="p">]</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{:30s}</span><span class="s2"> (</span><span class="si">{:d}</span><span class="s2">x</span><span class="si">{:d}</span><span class="s2">) </span><span class="si">{:15s}</span><span class="s2"> </span><span class="si">{:15s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">image_source</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">image_source</span><span class="o">.</span><span class="n">rows</span><span class="p">,</span>
                                                            <span class="n">image_source</span><span class="o">.</span><span class="n">cols</span><span class="p">,</span>
                                                            <span class="s1">&#39;,&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">image_formats</span><span class="p">),</span>
                                                            <span class="s1">&#39;,&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">pixel_formats</span><span class="p">)))</span>
    <span class="k">return</span> <span class="kc">True</span>


<div class="viewcode-block" id="ListImageSourcesCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.ListImageSourcesCommand">[docs]</a><span class="k">class</span> <span class="nc">ListImageSourcesCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;List image sources.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;list-sources&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;List image sources.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ListImageSourcesCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-name&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">ImageClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Image service to query&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Output of _show_image_sources_list method.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">_show_image_sources_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">,</span> <span class="n">service_name</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="GetImageCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetImageCommand">[docs]</a><span class="k">class</span> <span class="nc">GetImageCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get an image from the robot and write it to an image file.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;get-image&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get an image from the robot and write it to an image file.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetImageCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--outfile&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Filename into which to save the image&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--quality-percent&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">75</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Percent image quality (0-100)&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;source_name&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;SRC&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;+&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Image source name&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--service-name&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Image service to query&#39;</span><span class="p">,</span>
                                  <span class="n">default</span><span class="o">=</span><span class="n">ImageClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True if successful, False if exceptions are caught.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">image_requests</span> <span class="o">=</span> <span class="p">[</span>
            <span class="n">build_image_request</span><span class="p">(</span><span class="n">source_name</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">quality_percent</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">source_name</span> <span class="ow">in</span> <span class="n">options</span><span class="o">.</span><span class="n">source_name</span>
        <span class="p">]</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">response</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_image</span><span class="p">(</span><span class="n">image_requests</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">UnknownImageSourceError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Requested image source &quot;</span><span class="si">{}</span><span class="s1">&quot; does not exist.  Available image sources:&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">options</span><span class="o">.</span><span class="n">source_name</span><span class="p">))</span>
            <span class="n">_show_image_sources_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">service_name</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">service_name</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="k">except</span> <span class="n">ImageResponseError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Robot cannot generate the &quot;</span><span class="si">{}</span><span class="s1">&quot; at this time.  Retry the command.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">options</span><span class="o">.</span><span class="n">source_name</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="c1"># Save the image files in the correct format (jpeg, pgm for raw/rle).</span>
        <span class="n">save_images_as_files</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="LocalGridCommands"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.LocalGridCommands">[docs]</a><span class="k">class</span> <span class="nc">LocalGridCommands</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Commands for querying local grid maps.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;local_grid&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Commands for querying local grid maps.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LocalGridCommands</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span>
                                                <span class="p">[</span><span class="n">ListLocalGridTypesCommand</span><span class="p">,</span> <span class="n">GetLocalGridsCommand</span><span class="p">])</span></div>


<span class="k">def</span> <span class="nf">_show_local_grid_sources_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Print available local grid sources.</span>

<span class="sd">    Args:</span>
<span class="sd">        robot: Robot object on which to run the command.</span>
<span class="sd">        as_proto: Boolean to determine whether to print the full proto message, or just the list of</span>
<span class="sd">            names.</span>

<span class="sd">    Returns:</span>
<span class="sd">        True.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">proto</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LocalGridClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_local_grid_types</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">as_proto</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">proto</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">local_grid_type</span> <span class="ow">in</span> <span class="n">proto</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">local_grid_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
    <span class="k">return</span> <span class="kc">True</span>


<div class="viewcode-block" id="ListLocalGridTypesCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.ListLocalGridTypesCommand">[docs]</a><span class="k">class</span> <span class="nc">ListLocalGridTypesCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;List local grid sources.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;types&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;List local grid sources.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ListLocalGridTypesCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--proto&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;print listing in proto format&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Output of _show_local_grid_sources_list method.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">_show_local_grid_sources_list</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">as_proto</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">proto</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="GetLocalGridsCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.GetLocalGridsCommand">[docs]</a><span class="k">class</span> <span class="nc">GetLocalGridsCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get local grids from the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;get&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get local grids from the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">GetLocalGridsCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--outfile&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;filename into which to save the image&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;types&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;SRC&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;+&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;image types&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">LocalGridClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_local_grids</span><span class="p">(</span>
            <span class="n">options</span><span class="o">.</span><span class="n">types</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">local_grid_response</span> <span class="ow">in</span> <span class="n">response</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">local_grid_response</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DataAcquisitionCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataAcquisitionCommand">[docs]</a><span class="k">class</span> <span class="nc">DataAcquisitionCommand</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Acquire data from the robot and add it in the data buffer with the metadata, or request</span>
<span class="sd">    status.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;acquire&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Acquire data from the robot and add it in the data buffer with the metadata, or request</span>
<span class="sd">        status.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataAcquisitionCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span> <span class="p">[</span>
            <span class="n">DataAcquisitionServiceCommand</span><span class="p">,</span> <span class="n">DataAcquisitionRequestCommand</span><span class="p">,</span>
            <span class="n">DataAcquisitionStatusCommand</span><span class="p">,</span> <span class="n">DataAcquisitionGetLiveDataCommand</span>
        <span class="p">])</span></div>


<div class="viewcode-block" id="DataAcquisitionRequestCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataAcquisitionRequestCommand">[docs]</a><span class="k">class</span> <span class="nc">DataAcquisitionRequestCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Capture and save images or metadata specified in the command line arguments.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;request&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Capture and save images or metadata specified in the command line arguments.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataAcquisitionRequestCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--image-source&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;IMG_SRC&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Image source name&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--image-service&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;SERVICE_NAME&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Image service name for the image source.&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--data-source&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;DATA_SRC&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Data source name&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--action-name&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;The action name to save the data with.&#39;</span><span class="p">,</span>
                                  <span class="n">default</span><span class="o">=</span><span class="s2">&quot;quick_captures&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--group-name&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;The group name to save the data with.&#39;</span><span class="p">,</span>
                                  <span class="n">default</span><span class="o">=</span><span class="s2">&quot;command_line&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--non-blocking-request&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Return after making the acquisition request, without monitoring&#39;</span> <span class="o">+</span>\
                                      <span class="s1">&#39; the status for completion.&#39;</span><span class="p">,</span>
                                  <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the &#39;request&#39; command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">data_source</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">image_source</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">image_service</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">error</span><span class="p">(</span>
                <span class="s1">&#39;A request requires either a data source name or an image source+service name.&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">image_source</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">image_service</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">error</span><span class="p">(</span>
                <span class="s1">&#39;A request must have a 1:1 correspondence between image source and image service arguments.&#39;</span>
            <span class="p">)</span>

        <span class="n">captures</span> <span class="o">=</span> <span class="n">data_acquisition_pb2</span><span class="o">.</span><span class="n">AcquisitionRequestList</span><span class="p">()</span>
        <span class="n">captures</span><span class="o">.</span><span class="n">data_captures</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span>
            <span class="p">[</span><span class="n">data_acquisition_pb2</span><span class="o">.</span><span class="n">DataCapture</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">data_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">data_name</span> <span class="ow">in</span> <span class="n">options</span><span class="o">.</span><span class="n">data_source</span><span class="p">])</span>
        <span class="n">img_captures</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">src_name</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">image_source</span><span class="p">):</span>
            <span class="n">img_service</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">image_service</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
            <span class="n">img_captures</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                <span class="n">data_acquisition_pb2</span><span class="o">.</span><span class="n">ImageSourceCapture</span><span class="p">(</span><span class="n">image_service</span><span class="o">=</span><span class="n">img_service</span><span class="p">,</span>
                                                        <span class="n">image_source</span><span class="o">=</span><span class="n">src_name</span><span class="p">))</span>
        <span class="n">captures</span><span class="o">.</span><span class="n">image_captures</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">img_captures</span><span class="p">)</span>

        <span class="n">robot</span><span class="o">.</span><span class="n">time_sync</span><span class="o">.</span><span class="n">wait_for_sync</span><span class="p">(</span><span class="n">timeout_sec</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
        <span class="n">data_acquisition_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DataAcquisitionClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">success</span> <span class="o">=</span> <span class="n">acquire_and_process_request</span><span class="p">(</span><span class="n">data_acquisition_client</span><span class="p">,</span> <span class="n">captures</span><span class="p">,</span> <span class="n">options</span><span class="o">.</span><span class="n">group_name</span><span class="p">,</span>
                                              <span class="n">options</span><span class="o">.</span><span class="n">action_name</span><span class="p">,</span>
                                              <span class="n">block_until_complete</span><span class="o">=</span><span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">non_blocking_request</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">success</span></div>


<div class="viewcode-block" id="DataAcquisitionServiceCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataAcquisitionServiceCommand">[docs]</a><span class="k">class</span> <span class="nc">DataAcquisitionServiceCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get list of different data acquisition capabilities.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;info&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get list of different data acquisition capabilities.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataAcquisitionServiceCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

        <span class="c1"># Constants to describe width of columns for printing the data names and types</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_data_type_width</span> <span class="o">=</span> <span class="mi">15</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_data_name_width</span> <span class="o">=</span> <span class="mi">35</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_service_name_width</span> <span class="o">=</span> <span class="mi">35</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_has_live_data_width</span> <span class="o">=</span> <span class="mi">30</span>

    <span class="k">def</span> <span class="nf">_format_and_print_capability</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data_type</span><span class="p">,</span> <span class="n">data_name</span><span class="p">,</span> <span class="n">service_name</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">has_live_data</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Print the data acquisition capability.</span>

<span class="sd">        Args:</span>
<span class="sd">            data_type (string): Either image or data capabilities.</span>
<span class="sd">            data_name (string): The name of the data acquisition capability</span>
<span class="sd">            service_name(string): For image capabilities, a service name is required.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">print</span><span class="p">(</span>
            <span class="p">(</span><span class="s1">&#39;{:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data_type_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data_name_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span>
             <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_service_name_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;} {:&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_has_live_data_width</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;}&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                 <span class="n">data_type</span><span class="p">,</span> <span class="n">data_name</span><span class="p">,</span> <span class="n">service_name</span><span class="p">,</span> <span class="n">has_live_data</span><span class="p">))</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the &#39;info&#39; command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">capabilities</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span>
            <span class="n">DataAcquisitionClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_service_info</span><span class="p">()</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Data Acquisition Service&#39;s Available Capabilities</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_format_and_print_capability</span><span class="p">(</span><span class="s2">&quot;Data Type&quot;</span><span class="p">,</span> <span class="s2">&quot;Data Name&quot;</span><span class="p">,</span> <span class="s2">&quot;(optional) Service Name&quot;</span><span class="p">,</span>
                                          <span class="s2">&quot;(optional) has_live_data&quot;</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;-&quot;</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data_type_width</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data_name_width</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_service_name_width</span> <span class="o">+</span>
                     <span class="bp">self</span><span class="o">.</span><span class="n">_has_live_data_width</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">data_name</span> <span class="ow">in</span> <span class="n">capabilities</span><span class="o">.</span><span class="n">data_sources</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_format_and_print_capability</span><span class="p">(</span><span class="s2">&quot;data&quot;</span><span class="p">,</span> <span class="n">data_name</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">data_name</span><span class="o">.</span><span class="n">service_name</span><span class="p">,</span>
                                              <span class="nb">str</span><span class="p">(</span><span class="n">data_name</span><span class="o">.</span><span class="n">has_live_data</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">img_service</span> <span class="ow">in</span> <span class="n">capabilities</span><span class="o">.</span><span class="n">image_sources</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">img</span> <span class="ow">in</span> <span class="n">img_service</span><span class="o">.</span><span class="n">image_source_names</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_format_and_print_capability</span><span class="p">(</span><span class="s2">&quot;image&quot;</span><span class="p">,</span> <span class="n">img</span><span class="p">,</span> <span class="n">img_service</span><span class="o">.</span><span class="n">service_name</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">ncb_worker</span> <span class="ow">in</span> <span class="n">capabilities</span><span class="o">.</span><span class="n">network_compute_sources</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">model</span> <span class="ow">in</span> <span class="n">ncb_worker</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">data</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_format_and_print_capability</span><span class="p">(</span><span class="s2">&quot;models&quot;</span><span class="p">,</span> <span class="n">model</span><span class="o">.</span><span class="n">model_name</span><span class="p">,</span>
                                                  <span class="n">ncb_worker</span><span class="o">.</span><span class="n">server_config</span><span class="o">.</span><span class="n">service_name</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DataAcquisitionStatusCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataAcquisitionStatusCommand">[docs]</a><span class="k">class</span> <span class="nc">DataAcquisitionStatusCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get status of an acquisition request based on the request id.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;status&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Get status of an acquisition request based on the request id.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataAcquisitionStatusCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Response id to get the status for&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the &#39;status&#39; command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            False if NonexistentServiceError is caught, True otherwise.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DataAcquisitionClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span><span class="o">.</span><span class="n">get_status</span><span class="p">(</span>
            <span class="n">options</span><span class="o">.</span><span class="n">id</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="DataAcquisitionGetLiveDataCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.DataAcquisitionGetLiveDataCommand">[docs]</a><span class="k">class</span> <span class="nc">DataAcquisitionGetLiveDataCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Call GetLiveData based on service name.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;live&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Call GetLiveData based on service name.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">DataAcquisitionGetLiveDataCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--data-source&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;DATA_SRC&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Data source name&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the &#39;live&#39; command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True once complete.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">daq_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">DataAcquisitionClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">request</span> <span class="o">=</span> <span class="n">data_acquisition_pb2</span><span class="o">.</span><span class="n">LiveDataRequest</span><span class="p">()</span>
        <span class="n">request</span><span class="o">.</span><span class="n">data_captures</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span>
            <span class="p">[</span><span class="n">data_acquisition_pb2</span><span class="o">.</span><span class="n">DataCapture</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">data_name</span><span class="p">)</span> <span class="k">for</span> <span class="n">data_name</span> <span class="ow">in</span> <span class="n">options</span><span class="o">.</span><span class="n">data_source</span><span class="p">])</span>
        <span class="n">response</span> <span class="o">=</span> <span class="n">daq_client</span><span class="o">.</span><span class="n">get_live_data</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="HostComputerIPCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.HostComputerIPCommand">[docs]</a><span class="k">class</span> <span class="nc">HostComputerIPCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Determine a computer&#39;s IP address.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;self-ip&#39;</span>
    <span class="n">NEED_AUTHENTICATION</span> <span class="o">=</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Determine the IP address of the current computer used to talk to the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">HostComputerIPCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;The IP address of the computer used to talk to the robot is: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span>
              <span class="p">(</span><span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">common</span><span class="o">.</span><span class="n">get_self_ip</span><span class="p">(</span><span class="n">robot</span><span class="o">.</span><span class="n">_name</span><span class="p">)))</span></div>


<div class="viewcode-block" id="PowerCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PowerCommand">[docs]</a><span class="k">class</span> <span class="nc">PowerCommand</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Send power commands to the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;power&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Send power commands to the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PowerCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">subparsers</span><span class="p">,</span>
            <span class="n">command_dict</span><span class="p">,</span>
            <span class="p">[</span>
                <span class="n">PowerRobotCommand</span><span class="p">,</span>
                <span class="n">PowerPayloadsCommand</span><span class="p">,</span>
                <span class="n">PowerWifiRadioCommand</span><span class="p">,</span>
            <span class="p">])</span></div>


<div class="viewcode-block" id="KeepaliveCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.KeepaliveCommand">[docs]</a><span class="k">class</span> <span class="nc">KeepaliveCommand</span><span class="p">(</span><span class="n">Subcommands</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Send keepalive commands to the robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;keepalive&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Send keepalive commands to the robot.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">KeepaliveCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">,</span> <span class="p">[</span>
            <span class="n">KeepaliveGetStatusCommand</span><span class="p">,</span>
            <span class="n">KeepaliveRemovePoliciesCommand</span><span class="p">,</span>
        <span class="p">])</span></div>


<div class="viewcode-block" id="lease_details"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.lease_details">[docs]</a><span class="k">def</span> <span class="nf">lease_details</span><span class="p">(</span><span class="n">leases</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Returns list of &lt;resource_name&gt;:&lt;sequence&gt;, ...N.&quot;&quot;&quot;</span>
    <span class="n">lease_strings</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">lease</span> <span class="ow">in</span> <span class="n">leases</span><span class="p">:</span>
        <span class="n">sequence_string</span> <span class="o">=</span> <span class="s2">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">lease_seq</span><span class="p">)</span> <span class="k">for</span> <span class="n">lease_seq</span> <span class="ow">in</span> <span class="n">lease</span><span class="o">.</span><span class="n">sequence</span><span class="p">])</span>
        <span class="n">lease_strings</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">lease</span><span class="o">.</span><span class="n">resource</span><span class="si">}</span><span class="s2">:[</span><span class="si">{</span><span class="n">sequence_string</span><span class="si">}</span><span class="s2">]&quot;</span><span class="p">)</span>
    <span class="k">return</span> <span class="s2">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">lease_strings</span><span class="p">)</span></div>


<div class="viewcode-block" id="KeepaliveGetStatusCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.KeepaliveGetStatusCommand">[docs]</a><span class="k">class</span> <span class="nc">KeepaliveGetStatusCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Get status of keepalive service.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;status&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Call KeepaliveService GetStatus RPC.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">KeepaliveGetStatusCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-f&#39;</span><span class="p">,</span> <span class="s1">&#39;--full&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Show full GetStatus proto as json.&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">KeepaliveClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">status</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_status</span><span class="p">()</span>

        <span class="c1"># Give the option to print out the full message.</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">full</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">json_format</span><span class="o">.</span><span class="n">MessageToJson</span><span class="p">(</span><span class="n">status</span><span class="p">))</span>
            <span class="k">return</span> <span class="kc">True</span>

        <span class="c1"># If there are no policies, there probably isn&#39;t anything interesting here.</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">status</span><span class="o">.</span><span class="n">status</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No active policies&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>

        <span class="c1"># List all live policies in a concise message.</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">status</span><span class="o">.</span><span class="n">status</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Robot returned 1 live policy:&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Robot returned </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">status</span><span class="o">.</span><span class="n">status</span><span class="p">)</span><span class="si">}</span><span class="s2"> live policies:&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">live_policy</span> <span class="ow">in</span> <span class="n">status</span><span class="o">.</span><span class="n">status</span><span class="p">:</span>
            <span class="n">rough_robot_timestamp</span> <span class="o">=</span> <span class="n">status</span><span class="o">.</span><span class="n">header</span><span class="o">.</span><span class="n">response_timestamp</span><span class="o">.</span><span class="n">ToSeconds</span><span class="p">()</span>
            <span class="n">last_checkin</span> <span class="o">=</span> <span class="n">live_policy</span><span class="o">.</span><span class="n">last_checkin</span><span class="o">.</span><span class="n">ToSeconds</span><span class="p">()</span>
            <span class="n">time_elapsed</span> <span class="o">=</span> <span class="n">rough_robot_timestamp</span> <span class="o">-</span> <span class="n">last_checkin</span>
            <span class="c1"># Go through each action, and create a helpful message describing the status.</span>
            <span class="n">action_list</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">action</span> <span class="ow">in</span> <span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">actions</span><span class="p">:</span>
                <span class="n">name</span> <span class="o">=</span> <span class="n">action</span><span class="o">.</span><span class="n">WhichOneof</span><span class="p">(</span><span class="s2">&quot;action&quot;</span><span class="p">)</span>
                <span class="c1"># If this is a lease_stale or auto_return action, include some lease info.</span>
                <span class="n">name_maybe_with_details</span> <span class="o">=</span> <span class="n">name</span>
                <span class="k">if</span> <span class="n">action</span><span class="o">.</span><span class="n">HasField</span><span class="p">(</span><span class="s2">&quot;lease_stale&quot;</span><span class="p">):</span>
                    <span class="n">name_maybe_with_details</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">name_maybe_with_details</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">lease_details</span><span class="p">(</span><span class="n">action</span><span class="o">.</span><span class="n">lease_stale</span><span class="o">.</span><span class="n">leases</span><span class="p">)</span><span class="si">}</span><span class="s2">)&quot;</span>
                <span class="k">if</span> <span class="n">action</span><span class="o">.</span><span class="n">HasField</span><span class="p">(</span><span class="s2">&quot;auto_return&quot;</span><span class="p">):</span>
                    <span class="n">name_maybe_with_details</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">name_maybe_with_details</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">lease_details</span><span class="p">(</span><span class="n">action</span><span class="o">.</span><span class="n">auto_return</span><span class="o">.</span><span class="n">leases</span><span class="p">)</span><span class="si">}</span><span class="s2">)&quot;</span>
                <span class="c1"># Add an indicator if the policy action is active or not.</span>
                <span class="n">action_after_time</span> <span class="o">=</span> <span class="n">action</span><span class="o">.</span><span class="n">after</span><span class="o">.</span><span class="n">ToSeconds</span><span class="p">()</span>
                <span class="n">active_message</span> <span class="o">=</span> <span class="s2">&quot;NOT active&quot;</span>
                <span class="k">if</span> <span class="n">time_elapsed</span> <span class="o">&gt;</span> <span class="n">action</span><span class="o">.</span><span class="n">after</span><span class="o">.</span><span class="n">ToSeconds</span><span class="p">():</span>
                    <span class="n">active_message</span> <span class="o">=</span> <span class="s2">&quot;ACTIVE&quot;</span>
                <span class="n">action_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">name_maybe_with_details</span><span class="si">}</span><span class="s2"> after </span><span class="si">{</span><span class="n">action_after_time</span><span class="si">}</span><span class="s2"> seconds, </span><span class="si">{</span><span class="n">active_message</span><span class="si">}</span><span class="s2">&quot;</span>
                <span class="p">)</span>
            <span class="n">formatted_string</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;id: </span><span class="si">{</span><span class="n">live_policy</span><span class="o">.</span><span class="n">policy_id</span><span class="si">}</span><span class="se">\n</span><span class="s2"> client_name: </span><span class="si">{</span><span class="n">live_policy</span><span class="o">.</span><span class="n">client_name</span><span class="si">}</span><span class="se">\n</span><span class="s2"> last checkin </span><span class="si">{</span><span class="n">time_elapsed</span><span class="si">}</span><span class="s2">s ago&quot;</span>
            <span class="c1"># Only the supervisor policy seems to have a name.</span>
            <span class="k">if</span> <span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
                <span class="n">formatted_string</span> <span class="o">=</span> <span class="n">formatted_string</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2"> policy name: &#39;</span><span class="si">{</span><span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">&#39;&quot;</span>
            <span class="k">if</span> <span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">user_id</span><span class="p">:</span>
                <span class="n">formatted_string</span> <span class="o">=</span> <span class="n">formatted_string</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2"> user_id: &#39;</span><span class="si">{</span><span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">user_id</span><span class="si">}</span><span class="s2">&#39;&quot;</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">associated_leases</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">formatted_string</span> <span class="o">=</span> <span class="n">formatted_string</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2"> associated_leases: </span><span class="si">{</span><span class="n">lease_details</span><span class="p">(</span><span class="n">live_policy</span><span class="o">.</span><span class="n">policy</span><span class="o">.</span><span class="n">associated_leases</span><span class="p">)</span><span class="si">}</span><span class="s2">&quot;</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">formatted_string</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; actions:&quot;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">action</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">action_list</span><span class="p">):</span>
                <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;   </span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>

        <span class="c1"># If there is an action control action, we should indicate that.</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">status</span><span class="o">.</span><span class="n">active_control_actions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">for</span> <span class="n">action</span> <span class="ow">in</span> <span class="n">status</span><span class="o">.</span><span class="n">active_control_actions</span><span class="p">:</span>
            <span class="n">enum_name</span> <span class="o">=</span> <span class="n">keepalive_pb2</span><span class="o">.</span><span class="n">GetStatusResponse</span><span class="o">.</span><span class="n">PolicyControlAction</span><span class="o">.</span><span class="n">Name</span><span class="p">(</span><span class="n">action</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Active control action: </span><span class="si">{</span><span class="n">enum_name</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="KeepaliveRemovePoliciesCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.KeepaliveRemovePoliciesCommand">[docs]</a><span class="k">class</span> <span class="nc">KeepaliveRemovePoliciesCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Remove keepalive policies.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;remove&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Remove keepalive policies.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">KeepaliveRemovePoliciesCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--policy-id&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;+&#39;</span><span class="p">,</span>
                                  <span class="n">help</span><span class="o">=</span><span class="s1">&#39;Specify specific policy ids to remove.&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Implementation of the command.</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>

<span class="sd">        Returns:</span>
<span class="sd">            True.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">KeepaliveClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="n">current_policies</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_status</span><span class="p">()</span><span class="o">.</span><span class="n">status</span>
        <span class="n">current_policy_ids</span> <span class="o">=</span> <span class="p">[</span><span class="n">s</span><span class="o">.</span><span class="n">policy_id</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">current_policies</span><span class="p">]</span>

        <span class="c1"># If there are no policies, there probably isn&#39;t anything interesting here.</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">current_policies</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No active policies&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>

        <span class="n">to_rm</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">policy_id</span><span class="p">:</span>
            <span class="c1"># Remove specific policies.</span>
            <span class="k">for</span> <span class="n">policy_id</span> <span class="ow">in</span> <span class="n">options</span><span class="o">.</span><span class="n">policy_id</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">policy_id</span> <span class="ow">in</span> <span class="n">current_policy_ids</span><span class="p">:</span>
                    <span class="n">to_rm</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">policy_id</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Policy &#39;</span><span class="si">{</span><span class="n">policy_id</span><span class="si">}</span><span class="s2">&#39; not found.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Remove all current policies.</span>
            <span class="n">to_rm</span> <span class="o">=</span> <span class="n">current_policy_ids</span>

        <span class="n">client</span><span class="o">.</span><span class="n">modify_policy</span><span class="p">(</span><span class="n">policy_ids_to_remove</span><span class="o">=</span><span class="n">to_rm</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Removed </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">to_rm</span><span class="p">)</span><span class="si">}</span><span class="s2"> policies&quot;</span><span class="p">)</span>

        <span class="k">return</span> <span class="kc">True</span></div>


<div class="viewcode-block" id="PowerRobotCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PowerRobotCommand">[docs]</a><span class="k">class</span> <span class="nc">PowerRobotCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Control the power of the entire robot.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;robot&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Power cycle or power off robot computers.</span>

<span class="sd">        Note that this is only compatible with certain robots. Check HardwareConfiguration for details.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PowerRobotCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;cmd&#39;</span><span class="p">,</span> <span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;cycle&#39;</span><span class="p">,</span> <span class="s1">&#39;off&#39;</span><span class="p">])</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">robot</span><span class="o">.</span><span class="n">time_sync</span><span class="o">.</span><span class="n">wait_for_sync</span><span class="p">(</span><span class="n">timeout_sec</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lease_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">LeaseClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="k">with</span> <span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">LeaseKeepAlive</span><span class="p">(</span><span class="n">lease_client</span><span class="p">,</span> <span class="n">must_acquire</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                                <span class="n">return_at_exit</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
            <span class="n">power_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">PowerClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">cmd</span> <span class="o">==</span> <span class="s1">&#39;cycle&#39;</span><span class="p">:</span>
                <span class="n">power_cycle_robot</span><span class="p">(</span><span class="n">power_client</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">cmd</span> <span class="o">==</span> <span class="s1">&#39;off&#39;</span><span class="p">:</span>
                <span class="n">power_off_robot</span><span class="p">(</span><span class="n">power_client</span><span class="p">)</span></div>


<div class="viewcode-block" id="PowerPayloadsCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PowerPayloadsCommand">[docs]</a><span class="k">class</span> <span class="nc">PowerPayloadsCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Control the power of robot payloads.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;payload&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Power on or off robot payloads.</span>

<span class="sd">        Note that this is only compatible with certain robots. Check HardwareConfiguration for details.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PowerPayloadsCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;on_off&#39;</span><span class="p">,</span> <span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;on&#39;</span><span class="p">,</span> <span class="s1">&#39;off&#39;</span><span class="p">])</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">robot</span><span class="o">.</span><span class="n">time_sync</span><span class="o">.</span><span class="n">wait_for_sync</span><span class="p">(</span><span class="n">timeout_sec</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lease_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">LeaseClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="k">with</span> <span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">LeaseKeepAlive</span><span class="p">(</span><span class="n">lease_client</span><span class="p">,</span> <span class="n">must_acquire</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                                <span class="n">return_at_exit</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
            <span class="n">power_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">PowerClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">on_off</span> <span class="o">==</span> <span class="s1">&#39;on&#39;</span><span class="p">:</span>
                <span class="n">power_on_payload_ports</span><span class="p">(</span><span class="n">power_client</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">on_off</span> <span class="o">==</span> <span class="s1">&#39;off&#39;</span><span class="p">:</span>
                <span class="n">power_off_payload_ports</span><span class="p">(</span><span class="n">power_client</span><span class="p">)</span></div>


<div class="viewcode-block" id="PowerWifiRadioCommand"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.PowerWifiRadioCommand">[docs]</a><span class="k">class</span> <span class="nc">PowerWifiRadioCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Control the power of robot wifi radio.&quot;&quot;&quot;</span>

    <span class="n">NAME</span> <span class="o">=</span> <span class="s1">&#39;wifi&#39;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;Power on or off robot LTE radio.</span>

<span class="sd">        Note that this is only compatible with certain robots. Check HardwareConfiguration for details.</span>

<span class="sd">        Args:</span>
<span class="sd">            subparsers: List of argument parsers.</span>
<span class="sd">            command_dict: Dictionary of command names which take parsed options.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">PowerWifiRadioCommand</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;on_off&#39;</span><span class="p">,</span> <span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;on&#39;</span><span class="p">,</span> <span class="s1">&#39;off&#39;</span><span class="p">])</span>

    <span class="k">def</span> <span class="nf">_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
<span class="w">        </span><span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Args:</span>
<span class="sd">            robot: Robot object on which to run the command.</span>
<span class="sd">            options: Parsed command-line arguments.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">robot</span><span class="o">.</span><span class="n">time_sync</span><span class="o">.</span><span class="n">wait_for_sync</span><span class="p">(</span><span class="n">timeout_sec</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
        <span class="n">lease_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">LeaseClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
        <span class="k">with</span> <span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">lease</span><span class="o">.</span><span class="n">LeaseKeepAlive</span><span class="p">(</span><span class="n">lease_client</span><span class="p">,</span> <span class="n">must_acquire</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                                <span class="n">return_at_exit</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
            <span class="n">power_client</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ensure_client</span><span class="p">(</span><span class="n">PowerClient</span><span class="o">.</span><span class="n">default_service_name</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">on_off</span> <span class="o">==</span> <span class="s1">&#39;on&#39;</span><span class="p">:</span>
                <span class="n">power_on_wifi_radio</span><span class="p">(</span><span class="n">power_client</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">options</span><span class="o">.</span><span class="n">on_off</span> <span class="o">==</span> <span class="s1">&#39;off&#39;</span><span class="p">:</span>
                <span class="n">power_off_wifi_radio</span><span class="p">(</span><span class="n">power_client</span><span class="p">)</span></div>




<div class="viewcode-block" id="main"><a class="viewcode-back" href="../../../python/bosdyn-client/src/bosdyn/client/command_line.html#bosdyn.client.command_line.main">[docs]</a><span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="n">args</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Command-line interface for interacting with robot services.&quot;&quot;&quot;</span>
    <span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">(</span><span class="n">prog</span><span class="o">=</span><span class="s1">&#39;bosdyn.client&#39;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="n">main</span><span class="o">.</span><span class="vm">__doc__</span><span class="p">)</span>
    <span class="n">add_common_arguments</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">credentials_no_warn</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>


    <span class="n">command_dict</span> <span class="o">=</span> <span class="p">{}</span>  <span class="c1"># command name to fn which takes parsed options</span>
    <span class="n">subparsers</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_subparsers</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">&#39;commands&#39;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s1">&#39;command&#39;</span><span class="p">)</span>

    <span class="c1"># Register commands that can be run.</span>
    <span class="n">DirectoryCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">PayloadCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">FaultCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">RobotIdCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">LicenseCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">LogStatusCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">RobotStateCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">DataBufferCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">DataServiceCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">TimeSyncCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">LeaseCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">OldBecomeEstopCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">EstopCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">ImageCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">LocalGridCommands</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">DataAcquisitionCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">HostComputerIPCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">PowerCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>
    <span class="n">KeepaliveCommand</span><span class="p">(</span><span class="n">subparsers</span><span class="p">,</span> <span class="n">command_dict</span><span class="p">)</span>

    <span class="n">options</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">)</span>

    <span class="n">setup_logging</span><span class="p">(</span><span class="n">verbose</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">verbose</span><span class="p">)</span>

    <span class="c1"># Create robot object and authenticate.</span>
    <span class="n">sdk</span> <span class="o">=</span> <span class="n">bosdyn</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">create_standard_sdk</span><span class="p">(</span><span class="s1">&#39;BosdynClient&#39;</span><span class="p">)</span>
    <span class="n">sdk</span><span class="o">.</span><span class="n">register_service_client</span><span class="p">(</span><span class="n">DataAcquisitionPluginClient</span><span class="p">)</span>

    <span class="n">robot</span> <span class="o">=</span> <span class="n">sdk</span><span class="o">.</span><span class="n">create_robot</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">hostname</span><span class="p">)</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">options</span><span class="o">.</span><span class="n">command</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Need to specify a command&quot;</span><span class="p">)</span>
        <span class="n">parser</span><span class="o">.</span><span class="n">print_help</span><span class="p">()</span>
        <span class="k">return</span> <span class="kc">False</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">command_dict</span><span class="p">[</span><span class="n">options</span><span class="o">.</span><span class="n">command</span><span class="p">]</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">robot</span><span class="p">,</span> <span class="n">options</span><span class="p">):</span>
        <span class="k">return</span> <span class="kc">False</span>

    <span class="k">return</span> <span class="kc">True</span></div>
</pre></div>

           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
      
      &copy; Copyright 2025 Boston Dynamics. All rights reserved.
      <a href="https://www.bostondynamics.com/privacy-policy">Privacy Policy</a> | 
      <a href="https://www.bostondynamics.com/terms">Terms of Use</a>

    </p>
  </div> 

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(false);
      });
  </script>
    <!-- Theme Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'UA-XXXXXXX-1', {
          'anonymize_ip': false,
      });
    </script> 

</body>
</html>